Replace the url without refreshing the page in .net - asp.net

My default url home page is http://www.brindesbb.com/Pages/Default.aspx.
but I dont want to show Pages/Default.aspx in the address bar.
can anyone suggest me how to replace the url without reloading (refreshing ) the page.
Thanks in advance

You can do so in two ways IIS URL Rewriting and ASP.NET Routing
http://learn.iis.net/page.aspx/496/iis-url-rewriting-and-aspnet-routing/

What you want to do is URL Rewriting, read more here URL Rewriting in ASP.NET
Update: If you setup a new website(or edit the one you have) and point the /Pages directory as "root" and aspx is an default document the url will be as you want.

Technically that not possible with .net as .net is used on server side. and you need to change the URL which is on client side so... you will need to use JavaScript to manipulate the Browser URL history. Example [asp.net mvc] my url is http://localhost:123/Home/Product and I need to change it to http://localhost:123/Home/Product/301 this can be achieved by
<script>
window.history.pushState('', 'My Page', 'Home/Product/301');
</script>

Related

web.config image to web page redirect in .Net?

Is there a web.config code I can use to redirect the url of an image to an actual web page?
What can I do to make it so when someone access an image via their address bar by typing in: http://www.sitename.com/images/1.jpg
It will instead redirect the user to the web page: http://www.sitename.com/view/1.html
I want to still be able to place the images in image tags though.
Create Rewrite Rules as explained here. You can do it on the IIS manager.
You will only need a regular expression for detecting the matching URL strings and an action which in your case is a Rewrite.

changing page address format

I create a website with ASP.NET web form and I used URL friendly to shape my URLs , by URL friendly my URLs change but not enough for example one of my page "تور استانبول" URL after changing by URL friendly is Domain.com/tours/تور-استانبول/استانبول/1 but I want Domain.com/تور-استانبول/استانبول/
please note that I don't want to query on sql to rewrite to my page and also I don't want to create static page and because my pages are dynamic I can't write all of them in web config file
please help me in this case
Hamid, you can use asp.net routing. The following link contains explains how to do it:
https://msdn.microsoft.com/en-us/library/cc668201(v=vs.100).aspx
hope it helps

Asp.net 2.0 Hide Default.aspx from Url

I have one issue with my site. I need to hide Default.aspx from Url. My web site project uses urlrewriter net and I tried using it to make this but no success.
I read lot of articles on net how to do this but nothings work.
Does this is only possible to set on IIS ?
I wont all ways to have www.test.com instead of www.test.com/default.aspx
Please for best solution ?
If you're using iis 7 or above, this might be a way of going about it.
The Microsoft URL Rewrite Module 2.0 for IIS 7 and above enables IIS administrators to create powerful customized rules to map request URLs to friendly URLs that are easier for users to remember and easier for search engines to find. You can use the URL Rewrite module to perform URL manipulation tasks.
http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module
And heres a link to see the module in action.
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
After reading tons of articles this is solution for my problem..
setting this javascript onto masterpage
var testremove = location.href.toLowerCase().indexOf("default.aspx");
if (testremove != -1) {location.replace(location.href.substring(0,testremove))};

ASP.NET URL rewriting and redirecting

I am trying to wrap my head around a URL rewrtie / redirect project I need to work on. We currently have this url: http://www.example.com/Details/Detail.aspx?param1=8&param2=12345
Here is what the rewritten URL will look like: http://www.example.com/Param1/8/Param2/12345
I am using the ISAPI_Rewrite filter to allow for the "nice" url and make the page think it is still using the old url. That works fine.
Now, I need to redirect users, if they use the old URL, to the new URL. I figure I would need to use a combination of the filter and an HTTPModule / Handler to perform the redirect.
Any ideas?
Have you tried IIS URL Rewrite?
If you are not going to go down the System.Web.Routing (or use ASP.NET MVC) path then I would have a look at this link.
Using a HttpHandler would be your best bet. That way, you will be able to track all incoming requests, filter out the old format URLs and redirect them to the correct pages.

How to read rewritten url from an asp.net web page?

Most of the resources on the Internet seems to discuss how to do url rewriting in asp.net. None of them seem to discuss about how to read the rewritten url.
For example, I have rewritten:
http://www.test.com/users.aspx?id=12&name=sangam
to
http://www.test.com/profile/12/sangam.aspx
Now in the same page, at some point, I want to get this rewrittern url for the purpose of pointing return url in login link. Now a login link should be:
http://www.test.com/login.aspx?ReturnUrl=/profile/12/sangam.aspx
What is the proper way to achieve this? Thanks.
Try Request.RawUrl

Resources