Serve root application instead of subfolder - asp.net

At work we have an ASP.NET MVC application with a 'Notifications' namespace and accompanying folder.
The problem comes when trying to access /notifications - IIS it tries to serve files out of the notifications folder, instead of invoking the site's default application.
This is not a problem when deploying because the code folders aren't deployed, but during development, IIS sees the folder and tries to serve it.
Does anybody know how to make it just serve the default ASP.NET application for the folder? The closest I got was setting up a virtual folder, but that doesn't work because of the web.config inheritance behavior.

I'm afraid the only way to fix this is to rename either your folder or your controller. They can't be the same name because IIS looks inside of the folder first, and then if the folder does not exist, it goes to the ASP.NET ISAPI which then routes it to your controller.
Reference: http://forums.asp.net/t/1781586.aspx?+Help+Controller+not+getting+hit
Sorry :(

Related

Where does IIS look for files

Can anyone explain, please, exactly how .net works. I create a web site in Visual Studio and publish it to a local server to a folder at
D:\WebSites\Project1
I create a web site in IIS and provide the address of the folder containing the files for the web site. When I publish the site, using 'fixed naming and single page assemblies', all the .aspx files go in the folder on the D drive and a dll for each page goes in the bin folder inside that folder.
I would assume that when someone wants to view a page in their browser, IIS retrieves the file(s) required from the folder specified, they get processed and turned into html and sent to the browser.
Recently when someone clicked a button on a page that calls a web service - a file not found error was reported. Apparently
C:\Temp\bx5tn2js.dll
could not be found. The thing is - why did IIS decide to look in C:\Temp for a file?
And, in the error message was a load of references to xml serialization. What is being serialized?
This file looks like the compile files that asp.net generates on compile.
This folder can be setup on web.config on compilation session with the
tempDirectory="C:\Temp"
If you do not have set this option asp.net is use a default folder that is usually inside the asp.net directory, inside the windows folder. But if you have set this, and this folder did not have the correct permissions, then asp.net fails to compile the project, and you can get a message like that.

The requested page cannot be accessed because the related configuration data for the page is invalid

I am getting this error when I try to run an ASP.NET application without a web.config file.
The requested page cannot be accessed because the related configuration data for the page is invalid
as I read, we can run .NET applications without web config files, but when I tried it is giving me the error. I am using iis 7 on windows 7 machine.
When I create the application virtual directory inside inetpub/wwwroot it works fine. Why doesn't the other directory location?
One reason could be the version of .NET framework (on IIS or application pool level) is different from the application one.
Another reason could be if there are modules used in your web.config which the current configuration of IIS doesn't recognize. E.g. URL rewrite or other optional modules, which you have to explicitly enable before using.
This can be a reason:
If there is no Web.config file in the
UNC directory, IIS 7.0 uses the rules
that are defined for the parent
directory. For the Web content to be
served in this scenario, the
worker-process identity must have
access to the whole content directory.
Otherwise, the Web request is
rejected.
Details here.
You need to set permission for your Website folder or copy them to wwwroot folder.
If you choose to set permission, there are two ways:
Right click on Your Website folder, or
Right click to Your Website in IIS
Then select Edit permission and Add a permission (IUSR - default iis user)

IIS 6.0 web application - Does the entire "website" need to be an "application"?

I had a website hosted in IIS. One small section of it needed asp.net. So I just right-clicked that section/directory and made it an application and a virtual directory.
Is that alright? Or does the entire "website" need to be made into an application and virtual directory?
The reason I ask is that when I try to browse to the aspx page in this "application", I am getting a parser error message "Could not load type...MyCodeBehindType" in the page directive, which seems to me to indicate that it is not finding the dll's, or even the code behind class files (which are clearly in the same directory).
EDIT:
If I do it this way, with only a subfolder of my website actually being a web application, where do I put the dlls? In a bin folder of the website the web application is within? Or in a bin folder of the web application?
Making just a folder within a website, an application, should be fine. I usually have to remember to change the version of ASP.NET from 1.1 to 2.x, that may be what's causing the error.
In order to test the configuration, start with a blank test page (blank.aspx) with just HTML. If the HTML shows up, you know IIS is serving .NET pages.
If there is a problem with ASP.NET not being correctly registered for IIS, you could try re-registering it. Open the following folder:
%WindowsDir%\Microsoft.NET\Framework\x.x.x\
and run:
aspnet_regiis.exe -i

Nested virtual directory or application within sitecore site, is it possible

I would like to nest asp.net web app within sitecore site, something like this:
<sitecore web root folder>
.
<virtual directory/app folder>
I want to access sitecore site by using following url:
http://<whatever site name>
and I would like to access web app by using following url:
http://<whatever site name>/<whatever virtual directory/app alias>
Is this possible?
I tried it but when I try to access my web app (not sitecore) then web app complains about missing sitecore.
I believe that is because now I have two config files ans when accessing web app iis/asp.net processing first sitecore web.config.
Right, your assumption is correct. See Creating a project in a virtual directory under Sitecore root article for more information about this kind of setup.
You should be able to create a virtual app under a Sitecore root path. Because its an app it will use its own app pool and you can have a web.config for it. I guess the physical files will be OUTSIDE of the Sitecore Website folder but the from a URL you can make the virtual app located anywhere below the Sitecore root.

web.config in nested folder

I am trying to install an app inside of another web app. I have my .aspx pages and some code that I was putting into the main app's app_code folder. I've added my own web.config file for my connection string and such but I think there's a conflict. So my question is a two parter. First, what is the best way to install an app inside of another app, i.e should I use the main apps app_code folder or add my own, and second, would there be a conflict with the two web.config files. I was under the impression that the files pulled from the most specific web.config file. It appears there is a problem with my security and I am unable to access my file. I was attributing this to the two web.config files,
thanks.
If the nested application has had its folder turned into an application (right-click on it in IIS, Properties, and on the "Application" tab, "Create" a new application), you should put the code in the local App_Code folder:
- \RootFolder // Root of website
|- \App_Code // App_Code at root
|- \NewApplication // Seperate application in IIS, has "web in a box" icon in IIS
| |- \App_Code // App_Code of new application
If the nested application isn't a true application (in the IIS sense), then you will need to have the code files in the root App_Code folder.
This also has a bearing on your web.config - if the nested application is a true application, then you'll be able to have a full web.config at the level you want - however if it's not an IIS application, then there are limitations as to what you are able to put in subsequent web.configs - some elements are only allowed in the web.config at the application root, and can't be overridden by other settings.
What's the actual error you are seeing?
Regarding your first question, I would rather have them deployed on different folder. And second, if you have, for instance, a web site inside the default web site, you will have both web.config, but the more specific will override some of the attributes of the web.config from the default web site, but the ones that are not override will be there, (ie, HTTPHandlers, HTTPModules, the site will try to load those, so you will need to add the remove tag inside the HttpModules to remove them).
Hope this clarify your question

Resources