Link to home
Start Free TrialLog in
Avatar of Mr_Ezi
Mr_Ezi

asked on

Http Modules is not doing there job

Hello, the site I'm working on has a url rewriter to provite user freindly url's.

I switched to a new shared hosting and this stoped to work, the error is that the page can't be find. no error from the module.

Is there any way to debug  the module if it has a error it should tell it to me?

Thanks
<section name="httpsSection" type="myCode.HttpModules.HttpsRedirector.Configuration.HttpsRedirectSection, myCode.ECommerce.BusinessLayer" />

Open in new window

Avatar of ggupta7
ggupta7
Flag of India image

Avatar of Mr_Ezi
Mr_Ezi

ASKER

thanks for that link, what do you want me to see there?
Avatar of Mr_Ezi

ASKER

http://fashionseating.com.serv7.temphostspace.com/ this is the site, any link that should be redirected on it wont work.

The same web.config works great on the old host, it maybe a setting or what on the server to enable it?
Avatar of Todd Gerbert
Is the server IIS 6 or 7?  If it's 6 (and even possibly with IIS7, depending on server config), the way IIS works with ASP.Net is:

1

A request comes into IIS.

2

IIS checks the extension of the file requested - if it's something that IIS handles itself, like a .htm or .jpg, it continues checking that the file exists, the user has access, etc, and responds with the file content.

3

If the extension is .aspx (or something handled by ASP.Net), the request is handed off to the ASP.Net engine.

4

ASP.Net runs your HttpModule, the URL is re-written

5

The ASP.Net page is returned
So, if the incoming request is for "/somePage.htm" the process gets to step 2 and stops there, your HttpModule never runs.  If the incoming request is for "/someFolder" and that folder exists (but is empty) IIS will see that a folder name was requested without a file name, and automatically append the default document (which is probably default.aspx) - so now the request is actually for /someFolder/default.aspx, and since it's got a .ASPX extension step 3 hands off the request to ASP.Net, allowing your HttpModule a chance to run.  If, however, a request comes in for "/someFolder" and that folder does not exist, what happens is that IIS sees a request for a file named "someFolder" in the root.  Since there's no file extension, IIS attempts to handle the request itself (never passes it off to ASP.Net) - IIS sees there is no file named "someFolder" and returns the 404 error.
Avatar of Mr_Ezi

ASKER

Thank you for your explanation on how that works. So basically I see that the problem is in the rewriting in the beginning, in fact other modules do work so this may be the cause.

I'll copy the regex rewriting maybe the problem is there, its funny because the same does work on the old system.
That may be because the old system was configured to send every request to ASP.Net, regardless of file type, which can be done on IIS6, and I believe is the default on IIS7.  If the new system is not configured that way your application breaks.

If you're trying to re-write URLs like someserver.com/products/widgets/specificWidget/details to end up as someserver.com/productDetails.aspx?category=widgets&item=specificWidget, then you might need to make sure that the folders products, widgets, specificWidgets and details exist, and have a Default.aspx file in them.  This way, IIS will see that the folder /products exists, has a Default.aspx, and will transfer control of the request to ASP.Net.
Avatar of Mr_Ezi

ASKER

Here's the code in the web.config file that should rewrite the url's before going to the moudle.
<httpPatterns>
            <add pattern="^~/.*\.aspx[?]?"/>
            <add pattern="^~/.*\.html[?]?"/>
        </httpPatterns>		
	<!-- Rewrite Rules -->
	<rewriteRuleSection>
		<!-- Patterns describing URLs to be rewritten -->
		<rules>
			<add pattern="^~/.*_c(?&lt;idValue>\d+)\.html([?](?&lt;queryString>.*))?" replacement="~/Category-Info.aspx?CategoryID={idValue}&amp;{queryString}" />
			<add pattern="^~/.*_sc(?&lt;idValue>\d+)\.html([?](?&lt;queryString>.*))?" replacement="~/Specialty-Category-Info.aspx?CategoryID={idValue}&amp;{queryString}" />
			<add pattern="^~/.*_p(?&lt;idValue>[\d\w-]+)\.html([?](?&lt;queryString>.*))?" replacement="~/Product-Info.aspx?ItemCode={idValue}&amp;{queryString}" />
			<add pattern="^~/.*_sp(?&lt;idValue>[\d\w-]+)\.html([?](?&lt;queryString>.*))?" replacement="~/Specialty-Product-Info.aspx?ItemCode={idValue}&amp;{queryString}" />
			<add pattern="^~/Content/(?&lt;idValue>[\d\w-]+)/(.+)\.html([?](?&lt;queryString>.*))?" replacement="~/Handlers/Custom-Page-Handler.aspx?PageID={idValue}&amp;{queryString}" />
		</rules>
		 Patterns describing URLs to be skipped 
		<exceptions>
			<add pattern="^~/(AdminArea|UserArea)/.*" />
		</exceptions>
	</rewriteRuleSection>

Open in new window

URL re-writing is an HttpModule (probably, maybe you're using an ISAPI extension - either way it's not a built-in component of IIS, you need to install additional software).

You appear to be re-writing requests for ".html" files - if your hosting server's IIS is not configured to send all requests to ASP.Net, then the request for a .html file will never be handed off to the URL rewriting module (just one possible cause of pain).

What are you using to rewrite the URLs (your example doesn't quite look like the rules the URL Rewrite 2.0 module on my system generates)?

Is that URL rewriting module or ISAPI extension installed on the server you're using?  If not, is it registered in your web.config?
Avatar of Mr_Ezi

ASKER

So you say that this rewrite script in the web.config file works with a module?

I have the module there in the bin folder and its registered in the web.config.

So the only thing left to check is if my hosting server's IIS is configured to send all requests to ASP.Net.
Can you tell me where to set this so I could ask from the host to do it for me?

Thanks again.
So you say that this rewrite script in the web.config file works with a module?
I'm saying that those rules in your web.config work in conjunction with another piece of software, it could be a HttpModule or it could be an ISAPI extension of IIS.  Given that the rules are in your web.config, I think (but I'm not positive) that would indicate the URL rewriting is being done by a HttpModule.


I have the module there in the bin folder and its registered in the web.config.
You mean the URL rewriting module is in the bin folder and registered in web.config, or some other module?


...IIS is configured to send all requests to ASP.Net.  Can you tell me where to set this so I could ask from the host to do it for me?
If you just contact the hosting provider and let them know you need all requests, regardless of file type, to go through ASP.Net they should know how to do that (assuming they're willing to do so).  In IIS 7 it's done by setting the applicable application pool's Managed Pipeline Mode to "Integrated", in IIS 6 it's done by inserting a wildcard mapping that redirects all requests to the ASP.Net engine (http://professionalaspnet.com/archive/2007/07/27/Configure-IIS-for-Wildcard-Extensions-in-ASP.NET.aspx).
Avatar of Mr_Ezi

ASKER

Hello I contacted the host he replied:

We can setup this - however, you will need to purchase dedicated application pool for this (since all requests will be routed though asp.net isapi) and this is available at $50/yr. Once you confirm, we'll provide you with payment link and thereafter setup wildcard as per your requirement.

 I'd also note that you are on IIS 7 environment and Integrated pipeline mode is available which can be setup from extensions tab in website properties.

So I need to give them the $50 or it may be set by changing some properties?

Thanks again
Integrated pipeline mode should do it.
Avatar of Mr_Ezi

ASKER

I changed it to 2.0 Intergrated, the error stay's the same...

Should I try the dedicated pool?
Sorry, I forgot there's also a setting in web.config you need. Some along the lines of "runAllManagedModules..." - I don't remember what it is exactly, can look it up for you in a bit if you haven't found it yet
Set the runAllManagedModulesForAllRequests attribute of the <modules ..> tag to true.

<system.webServer>
	<modules runAllManagedModulesForAllRequests="true">
		<add name="TheRewriteModule" type="Blah.blah.blah"/>
		<add name="YourOtherMOdle" type="yada.yada.yada"/>
	</modules>
</system.webServer>

Open in new window


Avatar of Mr_Ezi

ASKER

Nope wont work :(

They made me the pool, I made the runAllManagedModulesForAllRequests="true" but still the same error!

I think maybe the user is not good? I see it says  Logon User: Anonymous.

http://fashionseating.com.serv7.temphostspace.com/Chairs_c1.html
Post your web.config.
Avatar of Mr_Ezi

ASKER

here:
 web.config
Thanks
1. IIS 7 uses the <system.webServer><modules>...</module></system.webServer> section, not the <system.web><httpModules></httpModules></system.web> section (I think you can leave them defined in both places to be able to use the same web.config on both versions of IIS).

2. You appear to have added a module named RewriterModule in the <modules /> section that points to the type Microdivision.ECommerce.BusinessLayer.HttpModules.Logger.LoggerModule, just a guess but I'm betting that type's probably supposed to read something like Microdivision.ECommerce.BusinessLayer.HttpModules.UrlRewriter.RewriterModule. ;)
Avatar of Mr_Ezi

ASKER

Is it possible to edit the config file and send it back?
Thanks
ASKER CERTIFIED SOLUTION
Avatar of Todd Gerbert
Todd Gerbert
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mr_Ezi

ASKER

Thank you so much