My question is really simple. I have a Web application with multiple sub-folders and there's no Default.aspx page in any of these.
How do I set the default page in each of these folders so users can type /folder instead of /folder/login.aspx?
Can this be done through the web.config file?
Should I just rename the file in each folder to Default.aspx?
Thanks!
There is a default document section for web.config, and you can even put a web.config in each folder, and inside that config just have the default document set.
There's a Default Document icon in the IIS section of your websites configuration panel. Open that up and you can add login.aspx to the list.
Related
I have an application where I have an XML file which holds the connection string.
When hit the URL with the exact file name it opens the file in the browser that is natural.
Now I need to restrict this file browsing and I can not change that code to do any redirect or anything else.
What I have tried is using denyurlsequences in the security tag in the web.config but it restricts the application too to access the file and that makes the application stop working.
I am using .NET Framework 2.0
The ".xml" file extension is not supported by ASP.NET pipeline that is why you cannot add it to web.config and restrict it. What you can do is to copy the xml file in the "App_Data" folder of your application.
The purpose of this folder is to hide it files from browsers/users and also is build for this type of data.
To create "App_Data" folder if it already does not exist :
Right click on your project -> Add ASP.NET Folder -> App_Data
Or just add a folder and call it App_Data
I know its old question but this answer may be helpful for others.
I did below configurations on IIS 8.5 ( make sure Request Filtering is installed on IIS.)
Open IIS and click on your application virtual directory.
In features View, Click on Request Filtering and then go to Hidden Segments tab - this tab will contain list of hidden files or folders. (like web.config, APP_data folder etc...)
Add file or folder you want to hide from the browsing by click on add hidden segment and mention file/folder name you want to hide and test it.
In our application we have a master xml file stored in an application folder, to deny browsing this xml file I had added the folder name in hidden segments and it worked.
I have upload functionality in my application. I was facing an upload issue and found out that in Web.Config there is httpRuntime tag. I set the change as below.
<httpRuntime requestValidationMode="2.0" maxRequestLength="2147483647" />
This fixed my upload issue. The above is my Web.Config in my root folder, one that we get by default.
Questions.
Can I create a seperate Web.config file? If Yes, I have to upload the files in some other Virtual Directory and my code is in some other project. So where shall i place the Web.Config file ?
Is it possible to set these settings at page level?
You can add a web.config file to nearly any folder (I doubt the app_data would allow it (but I could be wrong, however this is beside the point)).
You can of course (if possible) create many folders for each setting you need. In other words, have 1 file per folder to get around your issue.
Or, create a new parent folder which you want all sub folders to 'inherit' your new web.config file from. Your web.config file goes into this new parent folder.
Remember, the web.config file inherits from the parent web.config file, so you don't need to write the entire configuration again, just the section you want to add/overwrite.
I know its possible to specify the masterpage of all pages using the pages element of the web.config but is it possible to specify that for all the pages under /foo/ that they should have a certain master page, and specify this in the root web.config.
I know this can probably be achieved by putting another web.config in the subdirectories that I want that specific masterpage to override but if possible I'd like to keep all of it in the one spot as when we change one section master page we are most likely going to be changing a few of them.
Try to add location element in the roor web config file with configuration specific for the subdirectory. location Element (ASP.NET Settings Schema)
I have folder called Email which contains 20 aspx pages I am trying to apply master page to this email folder through web.config
i Got following error
The relative virtual path 'MasterPage.Master' is not allowed here.
code in web.config
Please help in this issue
Use an application-relative path, like ~/Email/MasterPage.Master
We have an application that is making use of the location tag in the web.config file at the machine level - meaning like C:\Windows\Microsoft.NET\Framework\v2.0...\CONFIG\web.config, the one that applies to the whole server - this application has lots of virtual directories under it and for each one there is a
<location path="IIS Web App Name\CustomerA">...
This seems to work ok for that app. But then we have a second app on the same server, and I'd like to add location tags to that app's web.config file - meaning the local web.config file in the app's directory - and have each one of them specify a location tag in a similar way.
Is this possible? Because it doesn't seem to work. I've tried:
<location path="My IIS App Name\CustomerA"> ...
and
<location path="CustomerA"> ...
and neither seem to work. I just need this location node to contain 1 node.
Is there maybe some
It would have to be a file or folder within that virtual. So I could set rules for "default.aspx" in the same root as the config file, or manage a folder like "Content" for the Content folder. I've done this successfully.
Or, put another config file in the folder you want to set custom rules for, and define rules there that will override the main...
HTH.