I have develop a asp.net mvc3 web application, in that i want upload images and videos.Images are save inserver path but when i upload more than 50MB video file it showing error
This webpage is not availableThe webpage at http://localhost:1318/Campaign/Advertises might be temporarily down or it may have moved permanently to a new web address.
Here are some suggestions:
Reload this web page later.
Error 101 (net::ERR_CONNECTION_RESET): The connection was reset.
This is i got the error please help me how can i resolve this to upload a file in server path .
Set this in your web.config file:
<httpRuntime maxRequestLength="<kilobytes allowed per upload>" />
so if you want to allow files up to 50 megs, set this.
<httpRuntime maxRequestLength="51200" />
Related
I have built a custom WCF service which is up and working fine.
I want service show message as metioned in below screen shot
though above exception comes my service is up and functional.
Reason why I'm getting above error is I'm trying to upload file along with filename (string) and FileContent(Stream).
public string ActivityAttachment(Stream Uploading, string CommentId, string FileName)
{
// My Code to save file on Server
}
But when I deploy the same solution in another machine I'm getting the SharePoint error which is redirect as mentioned in below screen shot.
Impact is that it's redirecting to error.aspx page whenever i'm trying to Upload file using xmlHttpRequest
(ignore sharepoint error message)
Just help how I can get service page rather SharePoint one.
You need to set the following in Your web.config file:
<compilation batch="false" debug="true" />
<customErrors mode="Off" />
I'm getting the following error while redirecting one page to another web page:
"the page was not displayed because the request entity is too large.".
The page from which I'm redirecting to another page contains a huge amount of data, so basically I know the cause of the issue.
However, I'm looking out for a working solution for this. Secondly, when I researched this issue I found such kind of problem generates when any large file gets uploaded.
But I'm not uploading any large file, its just the page itself contains large data. Prompt solution will be appreciated.
I think this will fix the issue if you have SSL enabled:
Setting uploadReadAheadSize in applicationHost.config file on IIS7.5 would resolve your issue in both cases. You can modify this value directly in applicationhost.config.
Select the site under Default Web Site
Select Configuration Editor
Within Section Dropdown, select "system.webServer/serverRuntime"
Enter a higher value for "uploadReadAheadSize" such as 1048576 bytes. Default is 49152 bytes.
During client renegotiation process, the request entity body must be preloaded using SSL preload. SSL preload will use the value of the UploadReadAheadSize metabase property, which is used for ISAPI extensions
Reference.
I got it working by doing the following
Go to IIS.
Click on the server name
In the features (icons), chose the configuration editor.
Click on the dropdowns on the top with Settings
Traverse the path system.webServer -> security -> requestFiltering -> maxAllowedContentLength and set it to 334217728. (Then hit enter and then apply on the top right).
You can also restart the webserver for good measure.
After that I could upload my 150k database to phpymyadmin.
I also set post_max size to 8000 in php.ini in programs/PHP/phpversion/php.ini
It may be overkill for the sizes but it gets the job done when you've got big files.
For me, uploadReadAheadSize did not fix my issue.
I changed both of these settings in my asp.net web.config and finally the file uploaded for me:
<system.web>
<system.webServer
<httpRuntime executionTimeout="999999" maxRequestLength="20000" requestValidationMode="2.0" /> <!-- 20 MB -->
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="20500000" /> <!-- 20.5 MB - making it match maxRequestLength to fix issue with uploading 20mb file -->
</requestFiltering>
</security>
</system.webServer>
Another possible cause is an Authentication setting. Within IIS7,
Select the site under Default Web Site
Select Authentication
Select Windows Authentication and enable. Disable all others.
While Windows Authentication is still selected, click on Advanced Settings in the Actions pane.
Make sure Extended Protection is on Accept and check the Enable Kernel-mode authentication
I had the same error and the above fix did not work. I was only on HTTP (localhost)
However this fixed the 413 error
Set-WebConfigurationProperty -filter /system.webserver/security/requestfiltering/requestLimits -name maxAllowedContentLength -value 134217728
I did the above but still had no joy.
What fixed the problem for me was also upping the request limits:
- Select site in IIS manager
- Click "Edit feature settings" from right hand menu
- Insert 200000000 for "Maximum allowed content length"
In my case, the error occurred when downloading a file.
The reason was, that I had a code that explicitely sends an HTTP 413 to the client in an (erroneous) case.
(See here for details).
So be aware of the fact that setting an HTTP response code 413 in your code (or in a library that you are using) also can generate the OP's error message.
I have this in my web.config:
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="UserFiles"/>
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
I think I am going about this the wrong way, but I can't seem to find the right way to google this. I want to grant download access to only that folder 'UserFiles'. I need to do this via the web.config since the live environment will be on Azure, so I will not have a machine to RDP into to change this is IIS.
First, if you are using Azure web role and not Azure Websites, you should be storing this stuff in a blob. Second, are these files needing to be secured so that only authenticated users can access them (or even users can only access their own files?).
Lets assume that anyone can download any file from the server. If that is the case, create a directory called UserFiles underneath content. Now, you can simply link to those files like so
MY File title
Now, if they are secured behind an authentication scheme, things get tricky. You don't want just anyone to be able to download those items. So, lets take a few steps to secure them.
1.Create a folder called UserFiles at the top level of your solution.
2.In your web.config, let's make it to where no one can access it
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="UserFiles"/>
</hiddenSegments>
</requestFiltering>
</security>
3.Create a MVC controller, lets call it files, that you actually will use to deliver the files to the user. In here, let's make an action called download that takes in a file Id (assuming you are storing file information in the database)
public FileResult Download(int id){
//perform logic to see if user has access to this file
//if access, return the file
//else return a 404
}
Now, your file download link will look like
#Html.ActionLink("My File Title", "Download", "Files", new{id = Model.Id})
MVC and your code will have access to the UserData folder, while an outside web user will not. Use the controller/action to gate your content
Files in App_Data will not be served to the end user, by design.
App_Data is used to store data files. From the MSDN:
App_Data contains application data files including .mdf database files, XML
files, and other data store files. The App_Data folder is used by
ASP.NET to store an application's local database.
The content of application folders... is not served in
response to Web requests, but it can be accessed from application code.
It would be pretty bad if people could download stuff, like your database, out of App_Data.
You'll need to move the UserFiles folder outside of App_Data.
I have develop a small asp.net MVC3 application in that i have upload a video files into Application server path.When i upload 2MB video file it is uploded .But when itry to upload 50mb file it is showing error like .
This webpage is not available
The webpage at http://localhost:1318/Campaign/Advertises might be temporarily down or it
may have moved permanently to a new web address.
Here are some suggestions:
Reload this web page later.
Error 101 (net::ERR_CONNECTION_RESET): The connection was reset.
I have set the execution time and maxrequested length in web.config file.
<httpRuntime maxRequestLength="20480" executionTimeout="12000"/>
How can i solve this please help me..
<httpRuntime maxRequestLength="51200" executionTimeout="0"/>
Here
executionTimeout="0" takes unlimited time
maxRequestLength="51200" for 1mb=1024 so for 50mb=51200
Just to make the answer more complete for the next guy:
httpRuntime goes in <system.web>
executionTimeout value of 0 only works for some versions of IIS
I have 2 asp.net mvc2 projects in a solution. One is normal site for visitors use and the other one is admin back-end which is going to be separated by sub-domains like test.com and admin.test.com. The scenario is like admin will add a new item(e.g product) with image and test.com will use that image to display product. Both application are sharing one db. so there is no problem to get the item details that is coming from the db. but for item image that has been uploaded in admin directory(admin.test.com) - any idea how to get it from general domain(test.com) to display??
Also what is the best way of separating the resources like image files or even css or js files across sites and how to access them?
p.s.I'm using shared hosting.
Thanks!
You can upload to a third sub-domain or to the front end domain.
You upload to a physical folder. This folder can be an appSetting value or so.
So, you get similar settings to those in web.config appSettings:
<add key="ProductImagesPhysicalFolder" value="x:\websites\frontend\product-images" />
<add key="ProductImagesFolderUrl" value="http://frontend.com/product-images" />
Upload to the physical folder (given you setup permission in ISS to allow write access to that folder), and have a helper method like GetProductImageUrl(string imageFilename) to get the URL of the image given its filename (saved in DB).