Balu99
Balu99

Reputation: 31

Asp.net Application_BeginRequest not fired, global.asax not run at server

For URL rewriting i have written code in global.asax

for just testing simply i'm trying to

string hurl = HttpContext.Current.Request.Url.AbsoluteUri.ToLower() if(hurl.Contains("atech.html")){HttpContext.Current.RewritePath("btech.html");}

i have also configure

<modules runAllManagedModulesForAllRequests="true"/>

this works in my local iis but i not run at my hosting server

giving 404 error.

Upvotes: 0

Views: 2847

Answers (3)

mirko cro 1234
mirko cro 1234

Reputation: 72

Try switch Managed Pipeline Mode from classic to integrated in Application pool

Upvotes: 1

Victor Ayala
Victor Ayala

Reputation: 61

I was able to fix this problem by publishing my web site using the option "delete all existing files prior to publishing", this option is located on the Publish wizard window, "Settings" > "File publish options".

In my case, for some unknown reason, execution of Application_BeginRequest on global.asax.cs was being ignored, I was able to confirm this problem adding a log entry within Application_BeginRequest, the log entry was never recorded.

Upvotes: 0

Madain
Madain

Reputation: 1

OK so here is the way I fixed this... IIS needs to be told which files to handle. In my case I needed some handlers for *.js files and *.php files to redirect to an aspx or ashx files.

Locally it works just fine but when i deploy all i get is 404's.

So you need to go into IIS. Find your site configuration and add entries in your Handler Mappings (IIS7, in IIS6 I think its in Application configuration) to handle *.XXX and have whatever handler you have for *.aspx handle it (usually its System.Web.UI.PageHandlerFactory)

And it should be fixed. Hope this helps

Upvotes: 0

Related Questions