Set default directory in Asp.net - asp.net

Is there a way to configure the default directory in web.config?
My Default.aspx file is not in the root folder but in /Public/Default.aspx.
I found this post : Set Default Page in Asp.net but it does't work, probably because it's only to configure the default page and not the default directory...

You'll want to configure this in IIS.
You have your website already setup, and all you need to do is add an "Application" within that website.
Add Application...
You can also create a Virtual Directory which would give a similar result. Unfortunately you will still be navigating to http://example.com/public/
My question to you is, what is in the wwwroot directory? Is there a different website? Why not launch two websites within IIS?
Here's more information C/O #waqas

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?

what is a root directory in IIS 6 and How do I make one of my subfolder in ASP.NET website the root directory?

I need to integrate a third party plugin in my asp.net website. To install the plugin, they have mentioned this sentence, "Create an application through your IIS control panel with root directory at -(some path from my website folder)?".
I am not much aware with IIS and rarely worked with it. Though I tried every possible way I could do in IIS, I am not able to work it out. After installation, there is a test page provided by plugin which I have to run to check but when I run it, it shows this error.
"It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS."
I searched this error too and found that it is because the two Web.Config file, one from the main project and another from plugin folder. The only way to work with this, is to make the plugin folder they specified as a root directory in IIS. Someone kindly tell me some easy steps to do this.
What I was doing is, in IIS6, I added New website with the main folder of my asp.net website, then I right click>add application and choose the given path, thought it would become root directory but it is not.
Help would be appreciated. Also note that, I have to put the plugin folder in my main website folder only. So, there are two web.config. I tried to rename one of them too, it solved the above error but gave another errors but I think main problem is of root directory. P.S they show me above error on web.config file of plugin folder on this sentence-
"Line 51:
< authentication mode="Windows" />"
Most of the times the root directory is C:\inetpub\wwwroot folder and "Default Web Site" on IIS Manager.
Open IIS Manager and under Sites there should be IIS websites and under it you will probably see Default website. You can see the root directory with Right click/Settings.
Copy your website files under this root directory.
And after copying folder to root folder you will see this folder under Default websites on IIS.
Right click your directory name on IIS and "Create Application", select correct .net framework.
It should be work. Good luck, if you need more help please give more details on your server IIS.

Deployed website shows it folder file list

I built Deployment package and feed IIS with that, but when I trying to visit my site, I see only files of root folder like FTP
Whats wrong ?
Do you have a default or index page? Also, in IIS you should disable directory browsing.

Prevent site directory from being displayed

I have a subdomain on which I have put up all the js code for my webiste to interact with another application. For eg: at code.example.com
Whenever, the user types this address,code.example.com, all the contents of the directory are listed. How do I prevent this thing? I do not have nay index.html or index.aspx here.
In your IIS Configuration, turn off Directory browsing.
If you say what version of IIS you're using, then we can give specific steps on how to turn directory browsing off.

ASP.NET site inside a virtual directory

I am currently putting a new version of my site online. I would like to retain the old site (for purposes of read only access) and have been directed to place it within a subfolder inside the directory where the site use to live. e.g.
www.example.com needs to be moved to www.example.com/old and the new site needs to be moved to www.example.com
Unfortunately I get the classic ASP.NET error when attempting to piggy back sites that each have their own web config.
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.
How can I compeletly seperate off the new site and access it via. www.example.com/old without ASP.NET trying to trickle down through my directories and find the main sites web.config?
Thanks!
Giving the site its own AppPool should work.
You can do this by creating an AppPool and then on the virtual directory in IIS setting the app pool to your new one in the properties.
Make sure that the virtual directory is an application and not just a virtual directory.
You may try the following setting in the site contained in the virtual dir:
<location inheritInChildApplications="false">
Rick Strahl has the same problem and describes his experiences on his blog.
Didn't try it out myself, but found other blog articles which use it successfully with IIS6.
I've tried both creating a new App Pool on the site. That's didn't work -- same errors. I also added the inheritChildApplications attribute directive in my web.config. That didn't work either. The only way I have been able to achieve what I needed was to add a new subdomain in an entirely new folder and put a redirect to it in my www.example.com/old page to old.example.com.
It's not what I was looking to do, but it solved the issue.

Resources