Cannot find Account/Authorize when MVC Web App - asp.net

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

Related

web.config application pool error after moving to new server

I have the following error after move my website from server to another server
I have already checked iis and make sure the app has an application pool and it points to the correct file path
here is a screenshot of my application pool
I even tried to add virtual directory and add application and still not working
Check siteMapFile attribute of sitemap
The possible reason behind the issue is:
When you create a new web application using visual studio.net, it automatically creates the virtual directory and configures it as an application. However, if you manually create the virtual directory and it is not configured as an application, then you will not be able to browse the application and may get the above error. The debug information you get as mentioned above, is applicable to this scenario. To resolve it, Right Click on the virtual directory - select properties and then click on "Create" next to the "Application" Label and the textbox. It will automatically create the "application" using the virtual directory's name. Now the application can be accessed.
When you have sub-directories in your application, you can have a web.config file for the sub-directory. However, there are certain properties that cannot be set in the web.config of the sub-directory such as authentication, session state (you may see that the error message shows the line number where the authentication or session-state is declared in the web.config of the sub-directory). The reason is, these settings cannot be overridden at the sub-directory level unless the sub-directory is also configured as an application (as mentioned in the above point). Mostly we have the practice of adding web.config in the sub-directory if we want to protect access to the sub-directory files (say, the directory is admin and we wish to protect the admin pages from unauthorized users). But actually, this can be achieved in the web.config at the application's root level itself, by specifying the location path tags and authorization.
in your case the site map section causing the issue. try to remove it from the config file.
You could refer this below link:
Nested ASP.NET 'application' within IIS inheriting parent config values?

How to create Application in the IIS Default Web Site root (virtual path : '/')?

Context
I have an Asp.Net MVC application. I would like to deploy it to an IIS (Windows Server 2016). I do not care which will be physical path, but I would like to access to the application in the virtual path '/'
(I am using Package web publish method, because no online access to the server, but I think this question is on IIS/ASP and not about publishing. I clearly miss some basic concept about IIS/ASP.)
What I've tried
1) When I try to create an Application in IIS then the dialog forces me to add an application Alias, which becomes the part of the virtual path. So regardless the physical path now the the url will be
myserver/myapp/mypage instead of myserver/mypage
which is not what I want. I would like to access to the page as myserver/mypage
2) If I simply deploy the app under wwwroot then it will appear as myserver/mypage it seems to be working, but where is the "Application" this case? (see picture).
Question
Maybe I missing something: Is this the Default Web Site is an "Application" in its own right? How to configure then its Application settings? If not, then how can I create an Application which's virtual path is '/'?
If I have understood your question correctly, you want to access the application as servername/pagename. In order to do so, do not create an "application" or "virtual directory" under a "website". Instead, directly host the content under Default website. You can change its path under "Basic Settings" and point it to your content folder.
You can also create another website at port 80 and point it to the location where your content is present. However, you will not be allowed to create 2 website with the same IP-port-hostname combination. You can solve this problem further in 3 ways.
If Default web site is not in use, then instead of creating another website, click on Default website, select basic setting from right hand panel and change the path to application content folder.
If Default website is in use, then create another another website at port 80 with a hostname.
If you do not have a hostname and are accessing the application using server-name, then you will have to modify the port to 8080 or something like that.
Refer my blog - https://blogs.msdn.microsoft.com/parvez/2016/07/27/iis-bindings/ for more information about IIS bindings

How to use host headers in IIS for a web application?

I have configured a website in IIS with a host header, so that I can call the url customhostheader/ and the website will be shown.
When I try to publish my web project, I get the error that some sections in web.config are registered as allowDefinition=MachineToApplication. But I cannot convert the website in to an application in IIS. I can only convert virtual directories into IIS applications, but I don't want the much longer url http://customhostheader/virtualdirectoryname, I prefer to have just http://customhostheader.
Any ideas what I could do?
Thanks.
Add an application with the name customhostheader which is pointing to your published code (parent of bin folder)
To do this
Right click on "Default Web Site" in IIS and select "Add
Application"
Give alias as customhostheader and provide the path to your application.
Edit based on the comment
Each website by default contains an application. So we just needs to make sure the path of the website is correct.
The following two points should be enough to set up the correct path
The path should be parent of bin folder
The web.config should be present on the path
The default document can be set through the IIS or web.config

Why is the w3wp.exe process looking on file system when an ASP.NET MVC controller is accessed?

Was just wondering if this was normal behavior as I'm fairly new to ASP.NET MVC. When I monitor the site usage via procmon I see the following:
7:19:17.0053886 PM w3wp.exe 3992 QueryOpen C:\www\inetpub\ControllerName.mvc\ActionName PATH NOT FOUND
(This site is setup to run on IIS6/MVC2 - the reason for the .mvc extention)
This is happening when the ControllName.mvc\ActionName URL is hit.
the .mvc extension is mapped to the ASP.NET runtime which processes the request using ASP.NET MVC engine. It does the following:
Starts the routing engine.
The "router" looks if the file in the request exists on the file system. If yes, it returns it to IIS which will render the static file.
If it does not exist, the ASP.NET routing executes appropriate actions.
So your log is the result of step 2 here. It is normally should not be performed.
I know one reason why it runs though: you have RouteExistingFiles set to true.
You need to check it to be set to false (which is the default).
One more observation is that w2wp looks for file in the root of inetpub, which means the application is located in the Root of the web site and not in the Virtual Directory.
If it is not true, then you should check the location of the application on disk and structure of the web site. Maybe there is just some collision.
Have you unticked the "Verify that file exists" box in IIS?
It's in the properties of the Website -> Home Directory -> Configuration -> Wildcard Application maps -> your existing aspnet map
Unfortunately, the screenshot on the Microsoft page has the box ticked while the text says "Uncheck the checkbox labeled Verify that file exists"

Wildcard application map causing error on umbraco homepage

I'm trying to setup my umbraco site so that it does not use the .aspx extension. I made the necessary changes to the config files, but when I added the wilcard application mapping in IIS the homepage now comes back with an object reference error (at System.Web.UI.Control.ResolveClientUrl) if I try to access it from at the root (i.e. http://site.com/). The error doesn't occur if I add the default.aspx or if I browse to /home (the root node). Is there something else I need to setup to get the root node to run at the root url?
This is actually a problem with asp.net rather than merely umbraco - I found the answer on a DotNetNuke forum. The ResolveClientUrl function cannot handle a '/' URL. This was fixed by installing the latest service pack for asp.net 2.0.

Resources