I am having routing weirdness. Are certain keywords a problem in route paths. For example, this route works:
routes.MapPageRoute("AdminLogin", "horse", "~/AdminAccount/Login.aspx");
But this route to the same resource fails:
routes.MapPageRoute("AdminLogin", "admin", "~/AdminAccount/Login.aspx");
It does a login redirect to the root loginform designated in the web.config file and the whole site locks up.
Found it. There was a folder in the project directory called Admin. It was defaulting to that folder, which is behind security.
Related
My MVC C# Web Site app is installed on an internal Azure App Service with a URL like app.domain.internal and resolved by client's DNS and certificates with another URL "app.externaldomain.com", so final users can access the site through "app.externaldomain.com" and the internal URL keeps unknown by users.
Almost everything works fine, the problem is that when code runs an Url.Action to generate URLs, it gets the app.domain.internal root and I need to change or overrite that root URL for "app.externaldomain.com", so the site can generate URLs like app.externaldomain.com/controller/action instead of app.domain.internal/controller/action (that is not accesible for final users).
There is a way to change the root URL used by MVC to generate fully qualified URLs with a custom root instead the URL of the App Service.
It is not factible to do an "url.replace('badroot', 'rigthroot')" or something similar in all the site.
I have an ASP.NET application (WebForms) A which serves mycompany.com URL.
I need to host new website (ASP.NET MVC) B on the same IIS, which serves mycompany.com/B/... pattern.
Main objective here is that, we want to keep mycompany.com domain in URL for branding issues.
How can I manage this?
The scenarios I already tried:
I defined mycompany.com/B pattern on load balancer, so that balancer can redirect specific request to my website B. In this scenario, webpage load was successful however resource files such as css, js, etc failed to load because they tried to load from mycompany.com insted of mycompany.com/B.
You can configure B as a virtual directory in A. In IIS manager, right-click on A, choose "Add application.." and configure B from the dialog you get.
Then, the B application will know that it is not a root application, and all helper methods in MVC that generate URLs will add the correct prefix (for example, Url.Action or will give you a url starting with /B/). With methods that take a URL as parameter (like Url.Content), you'll need to use a virtual URL, starting with ~/.
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
I'm using IIS7.5. I have a simple ASP.NET webforms site that uses basic URL rewriting in global.asax, intercepting requests for .aspx pages and passing them to various template pages.
For example, you can request http://www.mysite.com/default.aspx. In global.asax I first check if this exists as a "true" page. If it doesn't, I go off to the data store to get the details and redirect to template.aspx?page=default (or something similar).
This all works great. However, there's one issue. If I browse to http://www.mysite.com/default.aspx I get the page I expect. If I set the default document to default.aspx, either in the web.config or in IIS, then browse to http://www.mysite.com/ I get the error about directory browsing not being allowed.
Why is IIS ignoring the default document in this case? It appears to be because the file "default.aspx" doesn't exist. If this is the case, is there a workaround for the problem?
EDIT
To clarify, I don't have control over the IIS system and it's on really basic hosting, though I can request some changes, so I can't use any URL rewriting modules.
Workaround for you situation: Create Index.aspx as default document as physical file and redirect user to Default.aspx URL. So when user comes to mysite.com/ then index.aspx will kick in and force redirect to default.aspx which can then handle your template redirection logic.
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.