Solved

Http Modules is not doing there job

Posted on 2010-11-29
22
443 Views
Last Modified: 2012-05-10
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

0
Comment
Question by:Mr_Ezi
  • 11
  • 10
22 Comments
 
LVL 3

Expert Comment

by:ggupta7
ID: 34233592
0
 

Author Comment

by:Mr_Ezi
ID: 34233830
thanks for that link, what do you want me to see there?
0
 

Author Comment

by:Mr_Ezi
ID: 34233883
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?
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34239262
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.
0
 

Author Comment

by:Mr_Ezi
ID: 34239418
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.
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34239498
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.
0
 

Author Comment

by:Mr_Ezi
ID: 34239584
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

0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34240016
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?
0
 

Author Comment

by:Mr_Ezi
ID: 34240098
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.
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34240297
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).
0
 

Author Comment

by:Mr_Ezi
ID: 34240816
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
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34240929
Integrated pipeline mode should do it.
0
 

Author Comment

by:Mr_Ezi
ID: 34241093
I changed it to 2.0 Intergrated, the error stay's the same...

Should I try the dedicated pool?
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34241173
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
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34242027
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


0
 

Author Comment

by:Mr_Ezi
ID: 34242294
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
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34242315
Post your web.config.
0
 

Author Comment

by:Mr_Ezi
ID: 34242532
here:
 web.config
Thanks
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34242697
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. ;)
0
 

Author Comment

by:Mr_Ezi
ID: 34243047
Is it possible to edit the config file and send it back?
Thanks
0
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 500 total points
ID: 34243110
Nope. ;)

Aside from the fact that's your job, I don't want that responsability.  I'm also not familiar with your application, nor do I have access to the source code, documentation or any 3rd party tools you might have used, so you wouldn't want me doing it anyway (e.g. I have no way of knowing what the correct values are for the type names in your handlers/modules).

Mostly you can probably just copy/paste from HttpHandlers->handlers and HttpModules->modules.
0
 

Author Closing Comment

by:Mr_Ezi
ID: 34243795
Thank you so much
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now