ASP.NET Hide Site (in URL) - asp.net

When I navigate through my Website and access a new Site, by example:
Default.aspx
it would show in the URL-Bar: www.mySite.com/Default.aspx
But I want to hide this! -> So each time, it should stay: www.mySite.com
How to achieve this?

You could have a look at routing. Routing will enable you to add a path like www.mySite.com to a specific aspx file.
It's quit easy to setup in your global.asax :) You can check the following url for some info ASP.NET routing

If you want every page to have your main domain name only in the url, you could create a frame in your index page (f.ex. Default.aspx, or even better index.html):
<frameset>
<frame src="default2.aspx">
</frameset>
and then create your new startpage in default2.aspx.
However, frames have disadvantages, and your visitors wouldn't be able to copy the url - they would always return to your startpage.

Related

WebForms redirect page request for same page

Webforms using VB.NET. I have a page a.aspx that exists within a web app. I want to replace that page (with my own modified version) and call a new page b.aspx, but still call a.aspx if I need to. By design I cannot rename or change existing links in the application to a.aspx (out of my control).
Can I, using some sort of re-writing IIS module (or something more practical), create a new a.aspx that checks some server variable, if that is true then redirect to b.aspx, otherwise redirect to the original a.aspx, bypassing my code.
Thanks,
I think I understand your question, and you can solve it by using a Session variable. Something like:
If Session("YourVariableHere") = Nothing Then
Server.Transfer("b.aspx", True)
End If
Use this on your page A load.

Webforms: Redirect to home page

I want to redirect the user to the home page without actually having to reference the static page name like this:
context.Response.Redirect("home.aspx", false);
Instead I'd like to do something like:
context.Response.Redirect("/", false);
What would be the best way to do this?
Two ways.
rename your home.aspx to default.aspx because this is the default setting inside the web server for the homepage
You have to set the home.aspx as your homepage inside your webserver. E.g. if you hosting online and have the cPanel available you can do this there.
Or another solution could be to use routing:
https://msdn.microsoft.com/en-us/library/dd329551(v=vs.100).aspx
You could setup a route for the mapping "/" to the home.aspx page, something like:
routes.MapPageRoute("HomeRoute",
"/",
"~/home.aspx");

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

Hide page extension when first time loaded on server.. how can i do this task?

I have a simple task but I don't know about this. When we run a page for the first time the extension will be hidden like Default.aspx run on the browser for the first time .aspx will hidden.
You can use the URL Rewrite IIS module to allow the URLs typed and seen by the user to be completely different form the URLs used by the application.

how to force to default.aspx instead of www.domain.com

OK. I'm having a ridiculous problem. I'm trying to use URL rewrite to redirection from www.domain.com to www.domain.com/default.aspx.
I thought by setting default.aspx as the default document it would automatically drop the user there. But for some reason it still comes up www.domain.com.
The reason I want it to go to www.domain.com/default.aspx is that the login control on the page doesn't seem to want to work when it is just the www.domain.com. But of course if I type in the www.domain.com/default.aspx then the login works fine. The login control doesnt seem to post at all if it is www.domain.com. Anyway, I'm trying to avoid troubleshooting why the login control is not firing and just force it to land on default.aspx anytime someone tries to go to www.domain.com. I'm using IIS7. Any ideas here?
You could add something like this to your Default.aspx code behind (in your Page_Load method):
if (Request.Url.LocalPath == "/")
{
Response.Redirect("~/Default.aspx");
}
Note that the default document setting normally allows that page to be displayed under www.domain.com/ and www.domain.com/default.aspx (it doesn't do any redirecting for you).
The anwer has to do with a breaking change in ASP.NET 4. Answer was that the form action was empty action="" when on extensionless root url. but if on that same page, but had the name of the page in the url (blahblah.com/default.aspx) the action gets filled in. the easy fix for me was to put Me.Form.Action = "Default.aspx" on the page load of the home page. problem fixed.

Resources