Redirect to sub domain code

Discussion in 'General troubleshooting' started by wattouk, Apr 14, 2011.

  1. Hi

    I am having issues with the sample redirect code, i need to redirect all incoming requests to my url to a sub folder on my domain, i.e all requests to www.errl.co.uk need to go to www.errl.co.uk/n2CMS.

    I am using the following code in the head section on an default.aspx file on my domain route

    <script type='text/C#'>
    <%
    If InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("http://www.errl.co.uk/N2CMS") ) > 0 Then
    Response.Redirect("/N2CMS")
    ElseIf InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("http://www.errl.co.uk/N2CMS") ) > 0 Then
    Response.Redirect("/N2CMS")
    ElseIf InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("http://www.errl.co.uk/N2CMS") ) > 0 Then
    Response.Redirect("/N2CMS")
    End If
    %>
    </script>

    when i navigate to the url i get this error

    Compiler Error Message: CS1528: Expected ; or = (cannot specify constructor arguments in declaration)

    Source Error:

    Line 7: <script type='text/C#'>
    Line 8: <%
    Line 9: If InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("http://www.errl.co.uk/N2CMS") ) > 0 Then
    Line 10: Response.Redirect("/N2CMS")
    Line 11: ElseIf InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("http://www.errl.co.uk/N2CMS") ) > 0 Then

    can anyone kindly offer any advice on what im doing worng here?

    any advice anyone can offer will be greatly appreciated?

    Kind Regards

    L Watson
     
  2. Redirecting to a sub folder?

    Hi

    Can anyone point me in the right direction as to where i can find information on setting up a forward that will direct all incoming requests to my domain name to a sub folder on the domain. I also need the sub folder name not to show in the url.

    I have tried the sample code and followed the help doc from DASP on this and cant get it to work, they are apparently unable to help as its classed as a coding issue even though its their own code or help guide thats incorrect.

    Whats normally a simple request is turning out to be very time consuming and difficult to resolve. I would be very greatful if anyone could offer some advice?

    Thanks

    Liam
     
  3. Have you looked at the sample code in the DASP KB?
     
  4. Hi

    Thanks for your reply. Yes i have tried the code in the KB and followed the guidance but thats the code i cant get to work, this is the code

    <script type='text/C#'>
    <%
    If InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("http://www.errl.co.uk/N2CMS") ) > 0 Then
    Response.Redirect("/N2CMS")
    ElseIf InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("http://www.errl.co.uk/N2CMS") ) > 0 Then
    Response.Redirect("/N2CMS")
    ElseIf InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("http://www.errl.co.uk/N2CMS") ) > 0 Then
    Response.Redirect("/N2CMS")
    End If
    %>
    </script>

    When i got to the page i get the following error.

    Compiler Error Message: CS1528: Expected ; or = (cannot specify constructor arguments in declaration)

    Source Error:

    Line 7: <script type='text/C#'>
    Line 8: <%
    Line 9: If InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("http://www.errl.co.uk/N2CMS") ) > 0 Then
    Line 10: Response.Redirect("/N2CMS")
    Line 11: ElseIf InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("http://www.errl.co.uk/N2CMS") ) > 0 Then
     
  5. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    The code is Visual Basic. The script type you are using is C#.
     

Share This Page