Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



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

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 28-06-2011
Member
 
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.

Reply With Quote
  #2  
Old 28-06-2011
Member
 
Join Date: May 2009
Posts: 523
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.
Reply With Quote
  #3  
Old 28-06-2011
Member
 
Join Date: Apr 2009
Posts: 484
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>
Reply With Quote
  #4  
Old 28-06-2011
Member
 
Join Date: May 2009
Posts: 532
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>
Reply With Quote
  #5  
Old 28-06-2011
Member
 
Join Date: Apr 2009
Posts: 567
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>
Reply With Quote
  #6  
Old 28-06-2011
Member
 
Join Date: May 2009
Posts: 524
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>
Reply With Quote
  #7  
Old 28-06-2011
Member
 
Join Date: May 2009
Posts: 532
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>
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "IIS Module 2.0 of URL rewrite troubleshooting with Ajax enabled WCF service"
Thread Thread Starter Forum Replies Last Post
Motherboard MSI Z68a GD80 (B3) troubleshooting including Bad Customer service Yogisa Motherboard Processor & RAM 6 14-08-2011 12:55 AM
SatNav enabled Mobile Phone without 3G service Vance Portable Devices 6 03-08-2011 11:26 PM
IIS URL Rewrite and Silverlight calling the https WCF service fanish-war Technology & Internet 5 21-06-2011 12:21 PM
Unable to install 'URL rewrite Module' due to error code 1603 Ooopinder Windows Software 4 19-06-2011 11:10 AM
jQuery AJAX vs. Adobe AIR AJAX Class Agaev Windows Software 5 06-07-2010 02:59 PM


All times are GMT +5.5. The time now is 08:00 AM.