Remove or hide .aspx from url in asp.net
In this article I will explain how to remove or hide .aspx from URL in asp.net. Remove or hide .HTML from url in asp.net OR Remove or hide .HTM from url in asp.net. if you want to remove or hide .aspx extension from url in asp.net then
you need to use URL routing concept in asp.net.
but if you don't want to use URL routing in your code then you can use following code.
The main purpose of this task is make URL as SEO friendly.
Remove html or htm from url using code.
=> Add Global.asax file in your website or project
=> And add following code in your global.asax file
In this article I will explain how to remove or hide .aspx from URL in asp.net. Remove or hide .HTML from url in asp.net OR Remove or hide .HTM from url in asp.net. if you want to remove or hide .aspx extension from url in asp.net then
you need to use URL routing concept in asp.net.
but if you don't want to use URL routing in your code then you can use following code.
The main purpose of this task is make URL as SEO friendly.
Remove html or htm from url using code.
Other Articles - Step by step solution
------------------------------------------------------------------------
Chat application in asp.net
how to connect MS access in asp.net
how to access website in LAN
Three tier architecture in asp.net
Temp table in sql
Change the column name or datatype or size in sql server
Stored procedure with paging sql server
Calling web service without adding web reference
------------------------------------------------------------------------
Chat application in asp.net
how to connect MS access in asp.net
how to access website in LAN
Three tier architecture in asp.net
Temp table in sql
Change the column name or datatype or size in sql server
Stored procedure with paging sql server
Calling web service without adding web reference
------------------------------------------------------------------------
=> Add Global.asax file in your website or project
=> And add following code in your global.asax file
void Application_BeginRequest(object
sender, EventArgs e)
{
String WebsiteURL = Request.Url.ToString();
String[] SplitedURL = WebsiteURL.Split('/');
String[] Temp = SplitedURL[SplitedURL.Length -
1].Split('.');
// This is for aspx page
if (!WebsiteURL.Contains(".aspx")
&& Temp.Length == 1)
{
if (!string.IsNullOrEmpty(Temp[0].Trim()))
Context.RewritePath(Temp[0] + ".aspx");
}
/* // This is for HTML page
if (!WebsiteURL.Contains(".html") && Temp.Length == 1)
{
if (!string.IsNullOrEmpty(Temp[0].Trim()))
Context.RewritePath(Temp[0] +
".html");
}
// This is for HTM page
if (!WebsiteURL.Contains(".htm") && Temp.Length == 1)
{
if (!string.IsNullOrEmpty(Temp[0].Trim()))
Context.RewritePath(Temp[0] +
".htm");
}*/
}
=> Copy following div tag in your .aspx page , here you have to use page name only without .aspx extension
<div>
Remove
.aspx from asp.net website
<a href="Default">Click</a>
<%--Here write only page name
without extension --%>
</div>
=> You can also redirect page without extension
protected void Page_Load(object sender, EventArgs
e)
{
Response.Redirect("Default");
}
Thanks sir its working very well
ReplyDeletesir i have one problem please resolve .
ReplyDeleteif you have time
actually i am working on asp.net project and i want access my project on any to the any pc using local ip address .my all pc are connected at same lane
Thanks for your valuable comment.
DeleteI add one article for your problem , it help you.
Please check this
http://problemaspdotnet.blogspot.in/2015/06/how-to-access-aspnet-website-in-lan.html
Nice, its working very well. Thanks a lot...
ReplyDeleteit's working me too, thanks.
ReplyDeleteUrl for user and seo friendly.
It`s not working got an error on running this above code
ReplyDeleteError: HttpException was unhandled by user code
Request is not available in this context.
Error on line : String WebsiteURL = Request.Url.ToString();
please help me how to resolve it
Error on line : String WebsiteURL = Request.Url.ToString();
ReplyDeleteplease help me how to resolve it
Error on line : String WebsiteURL = Request.Url.ToString();
ReplyDeleteplease help me how to resolve it
Please try with HttpContext
Deletelike this
String WebsiteURL = HttpContext.Current.Request.Url.ToString();
This is very helpful , It is working like a charm...
ReplyDeleteThank you sir, It's working proper.
ReplyDeleteCan you please tell me - How to call webservice without adding web reference ?
Thanks.
Thanks for your valuable comment.
DeleteI have added one post for How to call web service without adding web reference, it will help you.
Please check this
How to call web service without adding web reference using C#
Thank you, Nice
ReplyDeleteThis is very helpful thank you so much sir....
ReplyDeleteits not working on online. ? any update for online
ReplyDeleteonly offline working