URL Rewriting in Global.asax error

Posted by Raj.Trivedi under ASP.NET on 11/14/2013 | Points: 10 | Views : 3179 | Status : [Member] [MVP] | Replies : 2
Hello Team,

We have done url re-writing using global.asax...

It works fine locally but when deployed to production server it does not find the url and does not redirect and give error resource not found.

In the bin folder I have App_global.asax.compiled and App_global.asax.dll file

The Global.asax file and the file which we are the file whose url is been written is in root folder.


Here is my Global.asax file code.

[code]

<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>

<script runat="server">

void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RouteTable.Routes.Clear();
RegisterRoutes(RouteTable.Routes);
}

public static void RegisterRoutes(RouteCollection routeCollection)
{
routeCollection.MapPageRoute("RouteForArticle", "Category/{CategoryTitle}/{ArticleID}/{Article}", "~/ArtView.aspx");
}

//void RegisterRoutes(RouteCollection routes)
//{
// routes.Add("ArticlePost", new Route("Category/{CategoryTitle}/{ArticleID}/{*Article}", new SiteRouteHandler() { PageVirtualPath = "~/ArtView.aspx" }));
//}

void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown

}

void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs

}

void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started

}

void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.

}

</script>
[/code]

I am also not getting the option to set the build type of global.asax to content in VS 2010.

I tried using ALT + Enter.

Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved



Responses

Posted by: Bandi on: 11/14/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Add "runAllManagedModulesForAllRequests="true" " in the <modules> element in the web.config

ReferenceS:
http://improve.dk/how-to-do-url-rewriting-on-iis-7-properly/
Check « Reply #8 on: June 08, 2010, 01:43:49 PM » reply in the following link
http://forum.arvixe.com/smf/general/asp-net-3-5-global-asax-url-rewriting-is-not-working/

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Raj.Trivedi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Learningtorise on: 11/18/2013 [Member] Starter | Points: 25

Up
0
Down
OR you can go through following post and implement as such:

http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx


http://hashtagakash.wordpress.com/

Raj.Trivedi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response