locked
Subdomain rewrite causes AJAX to malfunction RRS feed

  • Question

  • User-1941213043 posted

    After rewriting on my site using

    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules runAllManagedModulesForAllRequests="true"/>
     
      <rewrite>
          <rules>
            <clear />
    
            <rule name="Subdomain rewrite" stopProcessing="true">
              <match url=".*" />
              <conditions>
                <add input="{HTTP_HOST}" pattern="^www\.overflea\.com$" negate="true" />
                <add input="{HTTP_HOST}" pattern="^([^\.]+)\.overflea\.com$" />
              </conditions>
              <action type="Rewrite" url="/{C:1}{URL}" />
            </rule>
            
          </rules>
        </rewrite>
        <urlCompression doStaticCompression="true" doDynamicCompression="true" />
      </system.webServer>
    

    I started getting an error when trying to use AJAX:

    <soap:code><soap:value>soap:Receiver</soap:value></soap:code><soap:reason><soap:text xml:lang="en">System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, String arg) at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlTextReader.Read() at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read() at System.Xml.XmlReader.MoveToContent() at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.MoveToContent() at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement() at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing) --- End of inner exception stack trace ---</soap:text></soap:reason>

    Anyone have any ideas? Apparently the "Data at the root level is invalid" error is caused by malformed XML files... but if I remove the rewrite rule, it works.

    Wednesday, August 28, 2013 3:12 PM

Answers

  • User-166373564 posted

    Hi,

    From your description above, I'd like to suggest you to check whether your Directory Browsing is disabled,

    Enable directory browsing when you want client browsers to display a Web page that lists the contents of a directory when a request does not specify a document name and IIS cannot return a default document. A default document cannot be returned when IIS does not find a file in the directory that matches a file name specified in the IIS default document list, or when the Default Document feature is disabled in IIS,

    hope it helps,

    Regards

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 2, 2013 4:34 AM

All replies

  • User-1941213043 posted

    The above rule automatically rewrites for ALL subdomains.

    The following rewrite works for ajax and rewrites only for the subdomain specified (mubina), but does not work really well when it comes to redirecting to subdomain directories:

            <rule name="mub" enabled="true" stopProcessing="true">
              <match url="(.*)" />
              <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="^(www\.)?mubina\.overflea\.com$" />
              </conditions>
              <action type="Rewrite" url="/mubina/{R:0}" />
            </rule>
    



    Wednesday, August 28, 2013 3:27 PM
  • User-166373564 posted

    Hi,

    From your description above, I'd like to suggest you to check whether your Directory Browsing is disabled,

    Enable directory browsing when you want client browsers to display a Web page that lists the contents of a directory when a request does not specify a document name and IIS cannot return a default document. A default document cannot be returned when IIS does not find a file in the directory that matches a file name specified in the IIS default document list, or when the Default Document feature is disabled in IIS,

    hope it helps,

    Regards

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 2, 2013 4:34 AM