ASP.NET Friendly URLs 404 errors on IIS Application - asp.net

I'm using ASP.NET Friendly URLs in my web application project.
It works without any problem, but when I use IIS and Create Application under my default web site I get 404 error.
For example I have a page with URL address like this:
localhost/home/default.aspx
and I rewrite it to this address:
localhost/home/
with this line in routeconfig.cs:
routes.MapPageRoute("home", "home", "~/home/Default.aspx")
I refer to this new URL in my link by href="/home" and as I said it works ok until I use the application under IIS.
I created the application under my default web site in IIS with name APP1 and when I click on link with href="/home" my page address must be localhost/APP1/home but the address in address bar changes to localhost/home and I get 404 error.
Could you help me solve this problem?

The home page will not be localhost/app1/home - that's not how it works.
1 - Create an entry in your hosts file: -
127.0.0.1 app1
2 - Create a new website in IIS, pointing at the root folder of your website. Make sure you enter 'app1' into the 'Host name' field: -
3 - The home page of your new site is http://app1/home

Related

Cannot find Account/Authorize when MVC Web App

I have an MVC app having the following default routing map:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new {controller = "Startup", action = "Index", id = UrlParameter.Optional }
);
As long as I deploy this site to the root of my IIS server (c:\inetpub\wwwroot) and create a new website within IIS, everything works just fine.
However if I create a directory within the wwwroot folder structure, deploy the same files there and instead of creating a website, I create an Application underneath the DefaultWebSite and point it to the subfolder where the files reside (c:\inetpub\wwwroot\MyApplication); when I launch the WebApplication that previous was configured as a website, I get the error "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
Requested URL: http://localhost:80/Account/Authorize?client_id=web&response_type=token&state=
Physical Path: C:\inetpub\wwwroot\Account\Authorize
So it would appear that my routing needs to be adjusted to reflect the location of the app is in a subdirectory under wwwroot and not in wwwroot where it is looking.
What provisions should be taken to ensure an MVC Web "Application" runs properly under a Parent website?
=================================
UPDATED OBSERVATIONS
After considering a posted comment, I found a few more details of my issue may be noteworthy to mention.
My application is redirecting to the requested URL I posted by default, I am not doing it. In other words, if I open IIS, right-click my application under the DefaultWebSite and select browse; I am getting the incorrect URL. I don't ever recall having this issue with ASP.NET applications which suggests to me "routing" problem
If I alter the URL so that the Application Name precedes the Account/Authorize path I get redirected again to http://localhost/#access_token=&token_type=bearer&expires_in=1209600 and receive a blank content page that says "Beginning Execution" in the upper right hand corner. The title of the page says CORS Detection Script. Suggesting to me that my application possibly resides in a different domain that the default website??? Need some clarity on this though.
If I again precede the URL that landed me on the CORS Detection Script page with the Application Name, my page successfully loads as I'd expect
================================================
So again, I believe there are some adjustments required somewhere within my app (probably within the routing configuration) to compensate for the incorrect URL being generated by default.
Because if I setup the application as a website with all content at the root instead of a subdirectory, everything works.
Surely someone has seen this before
When you're creating an application in a subfolder of your website, you're effectively only changing the scope of the process running your app (w3p.exe). You will still need to put the application name in the url, like this:
http://localhost:80/MyApplication/Account/Authorize?etc

Remove solution/folder name from url in sitefinity project while running on localhost

I have one Telerik sitefinity project developed on other machine. When I configure the project on my system and run on localhost it takes folder/solution name in url. Therefore while clicking on links it give 404 not found error.
Url created now is:-
http://localhost:xxxx/ProjectName/home
What I want is:-
http://localhost:xxxx/home
Just create a new website in IIS and point it to the project folder.
Then browse it using the host header of the site, e.g. localhost or even something like mysite.localtest.me (*.localtest.me will point to 127.0.0.1)

SSL enabled URL (https://localhost:44301/) not working for ASP.Net MVC site

I'm having a problem to run SSL enabled ASP.Net MVC site. I tried to create an ASP.NET based MVC webpage. I followed following steps:
I've enabled the SSL property to True.
Copied the SSL URL (in my case it was localhost:44301).
In Solution Explorer, right clicked the SSLMVCTestApp and select Properties.
Select the Web tab.
Paste the SSL URL into the Project Url box, then click Create Virtual Directory.
Saved the project and Run the project.
The Browser is opened with URL containing https, however no page is shown and rather it shows the message : "This webpage is not available".
However, for non HTTPS url it is working. Can anyone please guide me to resolve this issue. I need to run Https enabled URL from my apps.
Thanks & Best Regards,
Ahmed
I think you don't need to do the steps 3 to 5.
Just run the project and open your url https://localhost:44301 in your browser.
And now, because of your action, maybe you need to remove the virtual directory you created in your ApplicationHost.config file

browsing an application's default page redirects to localhost/default.aspx and gives 404 error

There is a login page on my app, once I login, it should redirect to Default.aspx:
On VS local setup, the URL for redirect is like this-
"http://mydomain.com/testApp/account/Login.aspx?ReturnUrl=/Default.aspx"
which redirects to "http://mydomain.com/testApp/Default.aspx"
Now I have published an application on IIS7, and I am able to browse it directly.
But when I login, the redirect page is always coming as :
mydomain.com/Default.aspx instead of mydomain.com/testApp/Default.aspx.
I did try setting default page as testApp/Default.aspx, but this does not help.
Do I need to change the querystring for running on IIS?
If I run the app directly and type mydomain.com/testApp/Default.aspx, it works fine.
Any pointers?
Note: Please replace mydomain.com with locahost.
I figured the issue. The relative path in Query string for redirect should have ~ to access root folder after deployment on IIS.

Unable to open the landing page on server

I am using asp.net 3.5.
My Hosting provider has given me a folder to upload my publish application, now when I am entering www.example.com, I am not getting my homepage, but when I am running the same application on my local I am getting home page.
Please let me know what I have to modify so that when usertype www.example.com it will open like www.example.com/homepage.aspx
Please help.
Thanks in advance
The standard default page name for ASP.Net is Default.aspx, not homepage.aspx.
Rename the landing page to Default.aspx
Or, create a Default.aspx page and have it do a redirect homepage.aspx
Or, see if your hosting provider will configure your site to serve up homepage.aspx as the default page.
Could it be a domain name issue?
Locally you probably use http://localhost/homepage.aspx?
Has the domain name "www.mysite.com" been configured/activated for you by your provider?

Resources