I want to add the code below to the global.asax file. how do I do that in umbraco?
protectedvoidApplication_BeginRequest(objectsender, EventArgse){ //check the request to make it starts with www //and is not localhost (dev) if(!Request.Url.Host.StartsWith("www") && !Request.Url.IsLoopback) { //no ... redirect. UriBuilderbuilder = newUriBuilder(Request.Url); builder.Host = "www."+ Request.Url.Host; Response.Redirect(builder.ToString(), true); } }
Thank you very much for the reply... but actually this was the first thing that I tried but this leads to an error...
So after some research I found an article that said tha you could create your own Global.Asax that inherits from Umbraco.Global and after doing that you delete the App_Global.dll from the bin folder... Oh... and don't forget that the above class must override...
global.asax file
hello,
I want to add the code below to the global.asax file. how do I do that in umbraco?
protected void Application_BeginRequest( object sender, EventArgs e){
//check the request to make it starts with www
//and is not localhost (dev)
if (!Request.Url.Host.StartsWith( "www" ) && !Request.Url.IsLoopback)
{
//no ... redirect.
UriBuilder builder = new UriBuilder (Request.Url);
builder.Host = "www." + Request.Url.Host;
Response.Redirect(builder.ToString(), true );
}
}
Thanks in advance!
You could do it in a package.
The final step of a package installation can be a user control.
Within the user control you could add the code to write to the global.asax.
Best regards,
Marco
Thank you very much for the reply... but actually this was the first thing that I tried but this leads to an error...
So after some research I found an article that said tha you could create your own Global.Asax that inherits from Umbraco.Global and after doing that you delete the App_Global.dll from the bin folder... Oh... and don't forget that the above class must override...
is working on a reply...