Results 1 to 7 of 7

Thread: IIS Module 2.0 of URL rewrite troubleshooting with Ajax enabled WCF service

  1. #1
    Join Date
    Jun 2011
    Posts
    72

    IIS Module 2.0 of URL rewrite troubleshooting with Ajax enabled WCF service

    Can anyone help me! I use an application which uses Ajax enabled WCF service including IIS URL rewrite module 2.0. The WCF service seems to be not working when the application is deployed on IIS 7 on windows server 2008 R2 Enterprise edition with SP1 FRENCH machine. While debugging, the path http://localhost/WCFService.svc/jsdebug is redirected to the default.aspx page. This application works fine on a Windows Server 2008 R2 Enterprise edition with SP1 English machine but I am not able to find out the reason why the URL for the web service is redirected to the default.aspx page. I tried all the possible ways I could but it did not helped.

  2. #2
    Join Date
    May 2009
    Posts
    527

    Re: IIS Module 2.0 of URL rewrite troubleshooting with Ajax enabled WCF service

    Your problem seems to be unique. Actually the reason according to me is that you cannot create the URL rewrite on the root directory. For that you must have a directory between in order, so that Ajax can continue working. I am sure it will work for sure. If you use master pages then the links on the master pages won’t work on the pages that are in the subfolder where the URL rewriting is on. There might be a possibility of you needing two master pages i.e. one for first level and the other for second level.

  3. #3
    Join Date
    Apr 2009
    Posts
    488

    Re: IIS Module 2.0 of URL rewrite troubleshooting with Ajax enabled WCF service

    Even I am having problems related to it. I am using the below rules and for the URL rewriting I enabled the Failed request tracing, but the logs were empty.These rules are troubleshooting with Windows Server 2008 R2 French version only and on English version it is working fine:
    Code:
    <rule name="RedirectUserFriendlyURL1" stopProcessing="true">                                                          
    <match url="^Default\.aspx$" />                                                                                                           <conditions>                                                                                                                                                             <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
    <add input="{QUERY_STRING}" pattern="^P=([^=&]+)&L=([^=&]+)$" />                                     </conditions>                                                                                                                                                          <action type="Redirect" url="{C:1}/{C:2}" appendQueryString="false" />                                                    
    </rule> 
    rule name="RewriteUserFriendlyURL1" stopProcessing="true">                                                  
    <match url="^([^/]+)/([^/]+)/?$" />                                                                                                                   <conditions>                                                                                                                                                                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />                                          
    <add input="{URL}" negate="true" pattern="\.axd$">
    </conditions>
    <action type="Rewrite" url="Default.aspx?P={R:1}&L={R:2}" />                                                                          
    </rule>

  4. #4
    Join Date
    May 2009
    Posts
    539

    Re: IIS Module 2.0 of URL rewrite troubleshooting with Ajax enabled WCF service

    According to me the rules should be of the pattern "^([^/]+)/([^/]+)/?$". This will pass evaluation for the request "WCFService.svc/jsdebug". Also add a condition to negate svc requests in your rule, the rules should look like the:
    Code:
    <rule name="RedirectUserFriendlyURL1" stopProcessing="true">
    <match url="^Default\.aspx$" />
    <conditions>
    <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
    <add input="{QUERY_STRING}" pattern="^P=([^=&amp;]+)&amp;L=([^=&amp;]+)$" />
    </conditions>
    <action type="Redirect" url="{C:1}/{C:2}" appendQueryString="false" />
    </rule>
    <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
    <match url="^([^/]+)/([^/]+)/?$" />
    <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    <add input="{URL}" pattern="\.axd$" negate="true" />
    <add input="{URL}" pattern="\.svc" negate="true" />
    </conditions>
    <action type="Rewrite" url="Default.aspx?P={R:1}&amp;L={R:2}" />
    </rule>

  5. #5
    Join Date
    Apr 2009
    Posts
    569

    Re: IIS Module 2.0 of URL rewrite troubleshooting with Ajax enabled WCF service

    Still the application having the URL rewrite problem then you have to do some changes as I recommend. Just move the hosting services. Don’t move it to winhost, try some other hosting service. After doing this, your URL rewrite will work perfectly. The URL will look like http://www.mysite.com/band.aspx?band=u2 and it will be written to http://www.mysite.com/u2 . Put the following code in the webconfig file:
    Code:
    <rewrite>
    <rules>
    <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
    <match url="^([^/]+)/?$" />
    <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    <!-- The following condition prevents rule from rewriting requests to .axd files -->
    <add input="{URL}" negate="true" pattern="\.axd$" />
    </conditions>
    <action type="Rewrite" url="band.aspx?band={R:1}" /></rule>
    </rules> </rewrite>

  6. #6
    Join Date
    May 2009
    Posts
    529

    Re: IIS Module 2.0 of URL rewrite troubleshooting with Ajax enabled WCF service

    If the AJAX fails to load when site placed in the subfolder then you have to place the site within the subfolder using the below rewriting rule in a web.config file at the root level:
    Code:
    <rule name="Rewrite to folder1" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="^www.mydomain.org$" />
    </conditions>
    <action type="Rewrite" url="mysubfolder/{R:1}" />
    </rule>
    The generated code in default.aspx produces:
    Code:
    <script src="/mysubfolder/ScriptResource.axd?d=JqgWhplkVbNDB-O-
    ThhHizUoDTYJEM-feibV4yvf46HwrI2N5TzSy72-olJ4bTMQzD63KWlitLqI2oLdioZV-Q2&amp;
    t=ffffffff966badba" type="text/javascript">
    </script>
    But the generated code needs to produce:
    Code:
    <script src="/ScriptResource.axd?d=JqgWhplkVbNDB-O-
    ThhHizUoDTYJEM-feibV4yvf46HwrI2N5TzSy72-olJ4bTMQzD63KWlitLqI2oLdioZV-Q2&amp;
    t=ffffffff966badba" type="text/javascript">
    </script>

  7. #7
    Join Date
    May 2009
    Posts
    543

    Re: IIS Module 2.0 of URL rewrite troubleshooting with Ajax enabled WCF service

    To solve this rewrite problem once and for all then you have to perform certain steps as I recommend. After performing can have several asp.net web sites, using Ajax in one hosting account. First create a new subfolder for example “mysubfolder” then upload your new website into it. After that define the folder as an Application Starting point for example “mydomainname.com”. Create a web.config file directly in your root. After that add the following information to your web.config file:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <rewrite>
    <rules>
    <rule name="mydomainname.com" stopProcessing="true">
    <match url=".*" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="^(www.)?mydomainname.com" />
    <add input="{PATH_INFO}" pattern="^/mysubfolder/" negate="true" />
    </conditions>
    <action type="Rewrite" url="\mysubfolder\{R:0}" />
    </rule>
    </rules> 
    </rewrite>
    </system.webServer>
    </configuration>

Similar Threads

  1. Replies: 6
    Last Post: 13-08-2011, 11:55 PM
  2. SatNav enabled Mobile Phone without 3G service
    By Vance in forum Portable Devices
    Replies: 6
    Last Post: 03-08-2011, 10:26 PM
  3. IIS URL Rewrite and Silverlight calling the https WCF service
    By fanish-war in forum Technology & Internet
    Replies: 5
    Last Post: 21-06-2011, 11:21 AM
  4. Unable to install 'URL rewrite Module' due to error code 1603
    By Ooopinder in forum Windows Software
    Replies: 4
    Last Post: 19-06-2011, 10:10 AM
  5. jQuery AJAX vs. Adobe AIR AJAX Class
    By Agaev in forum Windows Software
    Replies: 5
    Last Post: 06-07-2010, 01:59 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,710,335.46126 seconds with 17 queries