Facing issues while trying to set Upload Limits settings in Page level - asp.net

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.

Related

Sitecore file drop area destination folder

I need to know if Sitecore Field File Drop Area can have different location set to save uploaded files?
I need to set different folder (media library) because content authors do not have access/rights to publish uploaded files in File Drop Area, saved under /System/.
The best part is that on Production Instance I do not have admin rights to modify security and access for content authors.
Question is: there is an option to set another destination folder on FileDropArea from CMS or only new written custom field can do it.
It looks like you can change the root folder, but you need to do it in the WebDAV config settings. The setting to change the root FileDropArea location is:
WebDAV.FileDropAreaMediaLocation
Its not in the sitecore config by default so add it via an include file:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="WebDAV.FileDropAreaMediaLocation" value="/sitecore/media library/my uploads" />
</settings>
</sitecore>
</configuration>
But I don't think you will need too. The files are not uploaded to the System area of the content tree, but the system folder in the Media Library.
As long as your editors are members of the sitecore/Authors role, they should have access to see this folder and its contents.

Restrict browsing an XML file using web.config

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.

Maximum upload size in ASP.NET

I understand that I can add the following to the web.config file:
<httpRuntime maxRequestLength="10096" executionTimeout="120"/>
This will increase the upload limit for the application. The problem is that the WEB.CONFIG file is part of the application and part of my installation. I have multiple customers with different values they want to use. The Web.config file is overwritten each time they install a new version of my application. Thus, this would overwrite any modifications to the upload size they might have made.
Currently I have my customers change the Machine.Config file, but this is really not the best solution as they are changing the parameters for the whole IIS Server.
I figured maybe I could have the customer add an App.Config to the folder, where they could set their own parameters. Since that file is not part of my installation, it would stay.
Has anyone else had this problem, figured out a way to work around having the customer have an ability to have their own custom config file that will not get overwritten when they install a new version of the application?
Thanks,
Cory
In web.config:
<httpRuntime configSource="httpRuntime.config"/>
In httpRuntime.config:
<httpRuntime maxRequestLength="10096" executionTimeout="120"/>
See the configSource attribute in General Attributes Inherited by Section Elements and SectionInformation.ConfigSource Property on MSDN for an explanation.

Setting folder default page in aspnet

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.

asp.net location tag not working

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.

Resources