HttpModules Rewrite with IIS 7http://forums.asp.net/t/1523171.aspx/1?HttpModules+Rewrite+with+IIS+7Fri, 12 Feb 2010 15:51:06 -050015231713666717http://forums.asp.net/p/1523171/3666717.aspx/1?HttpModules+Rewrite+with+IIS+7HttpModules Rewrite with IIS 7 <p>Hi,</p> <p><br> </p> <p>I try to make it works but I still have an error :(</p> <p>Any help would be super ... THANKS A LOT<br> </p> <p><br> </p> <p>This is my webconifg :</p> <p><br> </p> <p></p> <pre class="prettyprint">&lt;?xml version=&quot;1.0&quot;?&gt; &lt;!-- Note: As an alternative to hand editing this file you can use the web admin tool to configure settings for your application. Use the Website-&gt;Asp.Net Configuration option in Visual Studio. A full list of settings and comments can be found in machine.config.comments usually located in \Windows\Microsoft.Net\Framework\v2.x\Config --&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;section name=&quot;rewriter&quot; requirePermission=&quot;false&quot; type=&quot;Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter&quot; /&gt; &lt;/configSections&gt; &lt;rewriter&gt; &lt;!-- Rewrite department pages --&gt; &lt;rewrite url=&quot;^.*-d([0-9]&#43;)/?$&quot; to=&quot;~/Catalog.aspx?DepartmentID=$1&quot; processing=&quot;stop&quot;/&gt; &lt;rewrite url=&quot;^.*-d([0-9]&#43;)/page-([0-9]&#43;)/?$&quot; to=&quot;~/Catalog.aspx?DepartmentID=$1&amp;Page=$2&quot; processing=&quot;stop&quot;/&gt; &lt;!-- Rewrite category pages --&gt; &lt;rewrite url=&quot;^.*-d([0-9]&#43;)/.*-c([0-9]&#43;)/?$&quot; to=&quot;~/Catalog.aspx?DepartmentId=$1&amp;CategoryId=$2&quot; processing=&quot;stop&quot;/&gt; &lt;rewrite url=&quot;^.*-d([0-9]&#43;)/.*-c([0-9]&#43;)/page-([0-9]&#43;)/?$&quot; to=&quot;~/Catalog.aspx?DepartmentId=$1&amp;CategoryId=$2&amp;Page=$3&quot; processing=&quot;stop&quot;/&gt; &lt;!-- Rewrite product details pages --&gt; &lt;rewrite url=&quot;^.*-p([0-9]&#43;)/?$&quot; to=&quot;~/Product.aspx?ProductId=$1&quot; /&gt; &lt;/rewriter&gt; &lt;appSettings&gt; &lt;add key=&quot;PaypalEmail&quot; value=&quot;test@example.com&quot;/&gt; &lt;add key=&quot;PaypalCurrency&quot; value=&quot;USD&quot;/&gt; &lt;add key=&quot;PaypalReturnUrl&quot; value=&quot;http://www.example.com&quot;/&gt; &lt;add key=&quot;PaypalCancelUrl&quot; value=&quot;http://www.example.com&quot;/&gt; &lt;add key=&quot;MailServer&quot; value=&quot;mail.example.com&quot;/&gt; &lt;add key=&quot;MailUsername&quot; value=&quot;example&quot;/&gt; &lt;add key=&quot;MailPassword&quot; value=&quot;example&quot;/&gt; &lt;add key=&quot;MailFrom&quot; value=&quot;mail address&quot;/&gt; &lt;add key=&quot;EnableErrorLogEmail&quot; value=&quot;false&quot;/&gt; &lt;add key=&quot;ErrorLogEmail&quot; value=&quot;errors@example.com&quot;/&gt; &lt;add key=&quot;ProductsPerPage&quot; value=&quot;6&quot;/&gt; &lt;add key=&quot;ProductDescriptionLength&quot; value=&quot;70&quot;/&gt; &lt;/appSettings&gt; &lt;connectionStrings&gt; &lt;add name=&quot;TestShopConnection&quot; connectionString=&quot;Server=(local)\SqlExpress; Database=TestShop; User=sa; Password=password&quot; providerName=&quot;System.Data.SqlClient&quot;/&gt; &lt;remove name=&quot;LocalSqlServer&quot;/&gt; &lt;add name=&quot;LocalSqlServer&quot; connectionString=&quot;Server=(local)\SqlExpress;Database=TestnShop; User=sa; Password=password&quot; providerName=&quot;System.Data.SqlClient&quot; /&gt; &lt;/connectionStrings&gt; &lt;location path=&quot;AdminDepartments.aspx&quot;&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles=&quot;Administrators&quot;/&gt; &lt;deny users=&quot;*&quot;/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; &lt;location path=&quot;AdminCategories.aspx&quot;&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles=&quot;Administrators&quot;/&gt; &lt;deny users=&quot;*&quot;/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; &lt;location path=&quot;AdminProducts.aspx&quot;&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles=&quot;Administrators&quot;/&gt; &lt;deny users=&quot;*&quot;/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; &lt;location path=&quot;AdminProductDetails.aspx&quot;&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles=&quot;Administrators&quot;/&gt; &lt;deny users=&quot;*&quot;/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; &lt;location path=&quot;AdminProductAttributes.aspx&quot;&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles=&quot;Administrators&quot;/&gt; &lt;deny users=&quot;*&quot;/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; &lt;!-- Only administrators are allowed to access ShoppingCartAdmin.aspx --&gt; &lt;location path=&quot;AdminShoppingCart.aspx&quot;&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles=&quot;Administrators&quot;/&gt; &lt;deny users=&quot;*&quot;/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; &lt;location path=&quot;AdminOrders.aspx&quot;&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles=&quot;Administrators&quot;/&gt; &lt;deny users=&quot;*&quot;/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; &lt;!-- Only administrators are allowed to access AdminOrders.aspx --&gt; &lt;location path=&quot;AdminOrderDetails.aspx&quot;&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles=&quot;Administrators&quot;/&gt; &lt;deny users=&quot;*&quot;/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; &lt;!-- Only existing customers can access CustomerDetails.aspx --&gt; &lt;location path=&quot;CustomerDetails.aspx&quot;&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles=&quot;Customers&quot;/&gt; &lt;deny users=&quot;*&quot;/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; &lt;!-- Only existing customers can access Checkout.aspx --&gt; &lt;location path=&quot;Checkout.aspx&quot;&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles=&quot;Customers&quot;/&gt; &lt;deny users=&quot;*&quot;/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; &lt;!-- Only existing customers can access OrderPlaced.aspx --&gt; &lt;location path=&quot;OrderPlaced.aspx&quot;&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles=&quot;Customers&quot;/&gt; &lt;deny users=&quot;*&quot;/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; &lt;!-- Only administrators are allowed to access OrderTest.aspx --&gt; &lt;location path=&quot;OrderTest.aspx&quot;&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles=&quot;Administrators&quot;/&gt; &lt;deny users=&quot;*&quot;/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; &lt;system.web&gt; &lt;httpModules&gt; &lt;add name=&quot;UrlRewriter&quot; type=&quot;Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter&quot; /&gt; &lt;/httpModules&gt; &lt;profile&gt; &lt;properties&gt; &lt;add name=&quot;CreditCard&quot; type=&quot;System.String&quot;/&gt; &lt;add name=&quot;Address1&quot; type=&quot;System.String&quot;/&gt; &lt;add name=&quot;Address2&quot; type=&quot;System.String&quot;/&gt; &lt;add name=&quot;City&quot; type=&quot;System.String&quot;/&gt; &lt;add name=&quot;Region&quot; type=&quot;System.String&quot;/&gt; &lt;add name=&quot;PostalCode&quot; type=&quot;System.String&quot;/&gt; &lt;add name=&quot;Country&quot; type=&quot;System.String&quot;/&gt; &lt;add name=&quot;ShippingRegion&quot; type=&quot;System.String&quot;/&gt; &lt;add name=&quot;DayPhone&quot; type=&quot;System.String&quot;/&gt; &lt;add name=&quot;EvePhone&quot; type=&quot;System.String&quot;/&gt; &lt;add name=&quot;MobPhone&quot; type=&quot;System.String&quot;/&gt; &lt;/properties&gt; &lt;/profile&gt; &lt;roleManager enabled=&quot;true&quot;/&gt; &lt;globalization requestEncoding=&quot;utf-8&quot; responseEncoding=&quot;utf-8&quot; culture=&quot;en-US&quot;/&gt; &lt;!-- Set compilation debug=&quot;true&quot; to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development. --&gt; &lt;compilation debug=&quot;true&quot; targetFramework=&quot;4.0&quot;&gt; &lt;assemblies&gt; &lt;/assemblies&gt; &lt;/compilation&gt; &lt;!-- The &lt;authentication&gt; section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user. --&gt; &lt;authentication mode=&quot;Forms&quot;&gt; &lt;forms name=&quot;TestLogin&quot; loginUrl=&quot;Login.aspx&quot; timeout=&quot;60&quot; /&gt; &lt;/authentication&gt; &lt;!-- The &lt;customErrors&gt; section enables configuration of what to do if/when an unhandled error occurs during the execution of a request. Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace. &lt;customErrors mode=&quot;RemoteOnly&quot; defaultRedirect=&quot;GenericErrorPage.htm&quot;&gt; &lt;error statusCode=&quot;403&quot; redirect=&quot;NoAccess.htm&quot; /&gt; &lt;error statusCode=&quot;404&quot; redirect=&quot;FileNotFound.htm&quot; /&gt; &lt;/customErrors&gt; --&gt; &lt;customErrors mode=&quot;Off&quot; defaultRedirect=&quot;~/Oops.aspx&quot;&gt; &lt;error statusCode=&quot;404&quot; redirect=&quot;~/NotFound.aspx&quot;/&gt; &lt;error statusCode=&quot;500&quot; redirect=&quot;~/Oops.aspx&quot;/&gt; &lt;/customErrors&gt; &lt;pages theme=&quot;TestDefault&quot; controlRenderingCompatibilityVersion=&quot;3.5&quot; clientIDMode=&quot;AutoID&quot;&gt; &lt;controls&gt; &lt;add tagPrefix=&quot;asp&quot; namespace=&quot;System.Web.UI&quot; assembly=&quot;System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&quot;/&gt; &lt;add tagPrefix=&quot;asp&quot; namespace=&quot;System.Web.UI.WebControls&quot; assembly=&quot;System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&quot;/&gt; &lt;/controls&gt; &lt;/pages&gt; &lt;/system.web&gt; &lt;system.codedom&gt; &lt;/system.codedom&gt; &lt;!-- The system.webServer section is required for running ASP.NET AJAX under Internet Information Services 7.0. It is not necessary for previous version of IIS. --&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests=&quot;true&quot;&gt; &lt;add name=&quot;UrlRewriter&quot; type=&quot;Intelligencia.UrlRewriter.RewriterHttpModule&quot; /&gt; &lt;/modules&gt; &lt;validation validateIntegratedModeConfiguration=&quot;false&quot; /&gt; &lt;/system.webServer&gt; &lt;/configuration&gt;</pre><p><br></p> <p>And my page look like ...</p><p></p><pre class="prettyprint"> &lt;ItemTemplate&gt; &lt;h3 class="ProductTitle"&gt; &lt;a href="&lt;%# Link.ToProduct(Eval("ProductID").ToString()) %&gt;"&gt; &lt;%# HttpUtility.HtmlEncode(Eval("Name").ToString()) %&gt; &lt;/a&gt; &lt;/h3&gt;</pre> <p><br> But I've an IIS error which said :</p> <p><br> </p> &lt;div&gt; <fieldset><legend>Error Summary</legend> <h2>HTTP Error 404.0 - Not Found</h2> <h3>The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</h3> </fieldset> &lt;/div&gt; &lt;div&gt; <fieldset><legend>Detailed Error Information</legend>&lt;div id=&quot;details-left&quot;&gt; <table class="mceItemTable" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <th>Module</th> <td>IIS Web Core</td> </tr> <tr> <th>Notification</th> <td>MapRequestHandler</td> </tr> <tr> <th>Handler</th> <td>StaticFile</td> </tr> <tr> <th>Error Code</th> <td>0x80070002</td> </tr> </tbody> </table> &lt;/div&gt; &lt;div id=&quot;details-right&quot;&gt; <table class="mceItemTable" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <th>Requested URL</th> <td>http://localhost:80/Ecommerce/Im-Younger-Than-You-p22/</td> </tr> <tr> <th>Physical Path</th> <td>C:\inetpub\wwwroot\ASPNETEcommerce\22\BalloonShop\Im-Younger-Than-You-p22\</td> </tr> <tr> <th>Logon Method</th> <td>Anonymous</td> </tr> <tr> <th>Logon User</th> <td>Anonymous</td> </tr> </tbody> </table> &lt;/div&gt; </fieldset> &lt;/div&gt; &lt;div&gt; <fieldset><legend>Most likely causes:</legend> <ul> <li>The directory or file specified does not exist on the Web server. </li><li>The URL contains a typographical error. </li><li>A custom filter or module, such as URLScan, restricts access to the file. </li></ul> </fieldset> &lt;/div&gt; 2010-02-08T11:22:09-05:003666850http://forums.asp.net/p/1523171/3666850.aspx/1?Re+HttpModules+Rewrite+with+IIS+7Re: HttpModules Rewrite with IIS 7 <p>The only difference I can see between your code and mine is that I have preCondition set to &quot;&quot;:</p> <p><pre class="prettyprint">&lt;add name=&quot;UrlRewriter&quot; type=&quot;Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter&quot; preCondition=&quot;&quot; /&gt;</pre><br> </p> <p>I dont know if this makes a difference? (I am pretty new to iis7 myself)<br> </p> 2010-02-08T12:33:07-05:003666933http://forums.asp.net/p/1523171/3666933.aspx/1?Re+HttpModules+Rewrite+with+IIS+7Re: HttpModules Rewrite with IIS 7 <p>Thanks for your quick feedback... but it doesn't work either ... do you have that for rewrite ? I wonder if iis allow me wildcard :/<br> </p> <p><span>&nbsp;<span>&lt;</span><span>rewrite</span><span>&nbsp;</span><span>url</span><span>=</span><span>&quot;^.*-p([0-9]&#43;)/?&#36;&quot;</span><span>&nbsp;</span><span>to</span><span>=</span><span>&quot;~/Product.aspx?ProductId=&#36;1&quot;</span><span>&nbsp;</span><span>/&gt;</span><span> <br> </span></span></p> 2010-02-08T13:15:49-05:003675984http://forums.asp.net/p/1523171/3675984.aspx/1?Re+HttpModules+Rewrite+with+IIS+7Re: HttpModules Rewrite with IIS 7 <p>Hi </p> <p>sorry just a last question, i dont get why it doesnt work for me .... </p> <p>Just to know , do you have iis7?? if yes did you do something on it ...? <br> cuz it looks like my iis look for te folder instead of changing the url ... </p> <p>Thanks<br> </p> <p><br> </p> <p>http://localhost/Ecommerce/Anniversary-Balloons-d3/</p> &lt;div&gt; <fieldset><legend>Error Summary</legend> <h2>HTTP Error 404.0 - Not Found</h2> <h3>The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</h3> </fieldset> &lt;/div&gt; 2010-02-12T10:07:55-05:003676009http://forums.asp.net/p/1523171/3676009.aspx/1?Re+HttpModules+Rewrite+with+IIS+7Re: HttpModules Rewrite with IIS 7 <p>Hi tried your CustomTransformWithUrlRewriterNet solution. </p> <p>But it seems to come from IIS7 cuz it doesn't work either.</p> <p>http://forums.iis.net/t/1154026.aspx</p> <p><br> </p> 2010-02-12T10:29:29-05:003676022http://forums.asp.net/p/1523171/3676022.aspx/1?Re+HttpModules+Rewrite+with+IIS+7Re: HttpModules Rewrite with IIS 7 <p>Yes I have this working on an IIS7 server and I didnt set anything special up.</p> <p>I have extensionless url rewrites working as well as in www.example.com/manufacturer/</p> <p><br> </p> <p>I was talking to somebody yesterday about setting this up on IIS7 and I wrote a little guide for them to go with my IIS6 urlrewriter.net article:</p> <ul> <li><a href="/t/1523272.aspx#3675019">http://forums.asp.net/t/1523272.aspx#3675019</a></li></ul> <p><br> </p> <p>I just noticed that you are not specifying the assembly when you setup the add httpmodule line in iis7 web.config:</p> <p><span><span>&lt;</span><span>add</span><span>&nbsp;</span><span>name</span><span>=</span><span>&quot;UrlRewriter&quot;</span><span>&nbsp;</span><span>type</span><span>=</span><span>&quot;Intelligencia.UrlRewriter.RewriterHttpModule&quot;</span><span>&nbsp;</span><span>/&gt;</span><span> </span></span></p> <p><span><span>should be</span></span></p> <p><span><span>&lt;</span><span>add</span><span>&nbsp;</span><span>name</span><span>=</span><span>&quot;UrlRewriter&quot;</span><span>&nbsp;</span><span>type</span><span>=</span><span>&quot;Intelligencia.UrlRewriter.RewriterHttpModule</span></span><span><span>,&nbsp;Intelligencia.UrlRewriter</span></span><span><span>&quot;</span><span>&nbsp;</span><span>/&gt;</span><span> <br> </span></span></p> 2010-02-12T10:35:22-05:003676028http://forums.asp.net/p/1523171/3676028.aspx/1?Re+HttpModules+Rewrite+with+IIS+7Re: HttpModules Rewrite with IIS 7 <p>Otherwise my Application Pool is set as ASP.NET v4.0 Classic ??? u too <img src="http://forums.asp.net/tiny_mce/jscripts/tiny_mce/plugins/emotions/img/smiley-undecided.gif" alt="Undecided" title="Undecided" border="0">???</p> <p><br> </p> <p>thanks for this i will check ur link<br> </p> 2010-02-12T10:44:16-05:003676044http://forums.asp.net/p/1523171/3676044.aspx/1?Re+HttpModules+Rewrite+with+IIS+7Re: HttpModules Rewrite with IIS 7 <p><br> </p> 2010-02-12T10:58:02-05:003676159http://forums.asp.net/p/1523171/3676159.aspx/1?Re+HttpModules+Rewrite+with+IIS+7Re: HttpModules Rewrite with IIS 7 <p>sniiif </p> <p>Ive tried to update it online but i've the same error ... so its not my iis but my code :/</p> <p>http://onceuponatimejohanna.com/AppliSolVerte-p8/</p> 2010-02-12T11:55:15-05:003676225http://forums.asp.net/p/1523171/3676225.aspx/1?Re+HttpModules+Rewrite+with+IIS+7Re: HttpModules Rewrite with IIS 7 <p></p> <blockquote><span class="icon-blockquote"></span> <h4>sunnyshiny06</h4> <p></p> <p>Otherwise my Application Pool is set as ASP.NET v4.0 Classic ??? u too <img src="http://forums.asp.net/tiny_mce/jscripts/tiny_mce/plugins/emotions/img/smiley-undecided.gif" alt="Undecided" title="Undecided" border="0">???</p> <p><br> </p> <p>thanks for this i will check ur link<br> </p> <p></p> </blockquote> <p></p> <p>No I am running .net 3.5 which I believe would mean a 2.0 app pool?<br> </p> 2010-02-12T12:26:21-05:003676465http://forums.asp.net/p/1523171/3676465.aspx/1?Re+HttpModules+Rewrite+with+IIS+7Re: HttpModules Rewrite with IIS 7 <p>Everything now is conf like yours... maybe it's because my rewrite url is in an update ajax ..? :/<br> </p> 2010-02-12T15:02:48-05:003676544http://forums.asp.net/p/1523171/3676544.aspx/1?Re+HttpModules+Rewrite+with+IIS+7Re: HttpModules Rewrite with IIS 7 <p>Ok ive something new... I've one website which works ... and the other one not .... </p> <p>when I activate the trace ... this one who works has :</p> <pre class="prettyprint">&lt;b&gt;Response Headers Collection&lt;/b&gt;&lt;/h3&gt;&lt;/th&gt; &lt;/tr&gt;&lt;tr class=&quot;subhead&quot; align=&quot;left&quot;&gt; &lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Value&lt;/th&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;X-AspNet-Version&lt;/td&gt;&lt;td&gt;2.0.50727&lt;/td&gt; &lt;/tr&gt;&lt;tr class=&quot;alt&quot;&gt; &lt;td&gt;X-Powered-By&lt;/td&gt;&lt;td&gt;UrlRewriter.NET 2.0.0&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;Cache-Control&lt;/td&gt;&lt;td&gt;private&lt;/td&gt; &lt;/tr&gt;&lt;tr class=&quot;alt&quot;&gt; &lt;td&gt;Content-Type&lt;/td&gt;&lt;td&gt;text/html&lt;/td&gt;</pre><br> WHAT ABOUT YOU ?? <br>sorry for this and thanks a lot for your time <br></pre> <p><br> </p> 2010-02-12T15:51:06-05:00