Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Http Modules is not doing there job

Posted on 2010-11-29
22
Medium Priority
?
487 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 10
22 Comments
 

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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
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
 
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 2000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

704 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