HTTP Redirect

Discussion in 'Windows / IIS' started by IPAlarms, Dec 21, 2012.

  1. IPAlarms

    IPAlarms Developer of VoIP2Go Voice over IP Platform

    I just migrated from 2003 to 2012 and everything went smoothly. I have now reached the part I was dreading.... redirecting requests for my old ASP.Net web services over to an alternative server that still supports them.

    I can't believe how difficult Microsoft have made something that should be so simple. Anyhoo, there are applications out there consuming my web services at http://olddomain/myWS/myWS.asmx

    I have setup the web services at http://newdomain/myWS/myWS.asmx so my question is what is the quickest, dirtiest way to put a redirection in place on my new 2012 IIS 8 server so that requests are sent to the replacement server?
     
  2. IPAlarms

    IPAlarms Developer of VoIP2Go Voice over IP Platform

    I have IIS Manager connected up and ready to go....... I just haven't got a clue where to start.
     
  3. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    302 Redirects can be handled by the HTTP Redirect module. Other redirects can be handled using the URL Rewrite module.
     
  4. IPAlarms

    IPAlarms Developer of VoIP2Go Voice over IP Platform

    I am aware of both of those modules but I don't know how to use either of them. I have been unable to fond examples that come close to solving my specific problem and I was hoping someone could give me a step by step example.
     
  5. IPAlarms

    IPAlarms Developer of VoIP2Go Voice over IP Platform

    URL Rewrite is my preferred module but I get an error in my web.config when I use IIS Manager to add a mapping. Is there somewhere on the DASP server that I need to enable URL Rewrite?
     
  6. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

  7. What is the error message that you get when you setup URL Rewrite/Redirect rules on your URL Rewrite Module? Do you have a link we can look at?
     
  8. martino

    martino DiscountASP.NET Staff

  9. IPAlarms

    IPAlarms Developer of VoIP2Go Voice over IP Platform

    Thanks for your help guys :)

    There is no error in IIS Manager and the following code block gets inserted at the bottom of the web.config file in the root folder of my app:

    <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <staticContent>
    <mimeMap fileExtension=".cfg" mimeType="text/plain" />
    </staticContent>
    <rewrite>
    <rules>
    <rule name="wsVMRedirect" patternSyntax="ExactMatch">
    <match url="http://www.ipalarms.net/wsvm/wsvm.asmx" />
    <action type="Rewrite" url="http://vm.thruhere.net/wsvm/wsvm.asmx" />
    </rule>
    </rules>
    </rewrite>
    </system.webServer>

    I download the web.config file and open it in Visual Studio 2012. The <rewrite> tag is underlined and when I put my mouse over it the error is: The element 'system.webServer' has invalid child element 'rewrite'. It then goes on to give a list of possible elements that are expected.

    I also tried inserting the rewrite code block in the web.config file in the wsVM folder, but either way, the redirect does not work.
     
  10. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    That's because the <rewrite> XML tag should not be a child element of <system.webServer>. The format should look like this:

     
  11. IPAlarms

    IPAlarms Developer of VoIP2Go Voice over IP Platform

    So the URL Rewrite module in IIS Manager does not work correctly. As a fix, I edited the web.config manually and tried the following outside of the system.webServer element and I get an error as I request the .asmx

    <rewriter>
    <rewrite />
    <rules>
    <rule name="wsVMRedirect" patternSyntax="ExactMatch">
    <match url="http://www.ipalarms.net/wsvm/wsvm.asmx" />
    <action type="Rewrite" url="http://vm.thruhere.net/wsvm/wsvm.asmx" />
    </rule>
    </rules>
    </rewriter>

    also tried:

    <rewriter>
    <rewrite>
    <rules>
    <rule name="wsVMRedirect" patternSyntax="ExactMatch">
    <match url="http://www.ipalarms.net/wsvm/wsvm.asmx" />
    <action type="Rewrite" url="http://vm.thruhere.net/wsvm/wsvm.asmx" />
    </rule>
    </rules>
    </rewrite>
    </rewriter>
     
  12. IPAlarms

    IPAlarms Developer of VoIP2Go Voice over IP Platform

    Can anyone help me with a workaround?
     
  13. I think we are looking at this all wrong. We are troubleshooting base of what your VS shows. You probably don't have the URL Rewrite Module installed on your computer that is why VS does not recognize the element. If the server itself does not recognize the element, you would definitely see the error on your browser. I suspect it maybe the rules and conditions you setup. But it is hard to say because the currently rules you maybe setting is a bit complex.

    Rather setup a simple rule, where if some one types http://ipalarms.net it gets rewritten/redirected to http://www.ipalarms.net. Let's start from there and work our way to a more sophisticated rule.
     

Share This Page