Most (if not all) web sites will have a default start page for example, default.aspx, index.aspx, home.aspx, etc. The default start page kicks in when someone goes to a url that does not refer to the page (no file extension) but possibly to a folder - for example, example.com/ or example.com/test . Without the default page, the user will be shown or not shown the directory listing page depending on the IIS configuration. For security reasons, it's better not to show end users the directory listing page. I once saw an application with directory listing that was showing the log folder and files.
May 1, 2014
January 5, 2014
November 21, 2010
The asp.net FileUpload control allows a user to browse and upload files to the web server. From developers perspective, it is as simple as dragging and dropping the FileUpload control to the aspx page. An extra control, like a Button control, or some other control is needed, to actually save the file.
By default, the FileUpload control allows a maximum of 4MB file to be uploaded and the execution timeout is 110 seconds. These properties can be changed from within the web.config file’s httpRuntime section. The maxRequestLength property determines the maximum file size that can be uploaded. The executionTimeout property determines the maximum time for execution.
From code behind, the mime type, size of the file, file name and the extension of the file can be obtained. The maximum file size that can be uploaded can be obtained and modified using the System.Web.Configuration.HttpRuntimeSection class.
Files can be alternatively saved using the System.IO.HttpFileCollection class. This collection class can be populated using the Request.Files property. The collection contains HttpPostedFile class which contains a reference to the class.
November 15, 2010
Http handlers in asp.net implement the System.Web.IHTTPHandler interface and provides low level Request and Response API to respond to the incoming Http requests. Using this method, we can setup a different file extension instead of .aspx to handle the request.
In this example, I will create a simple handler and use .example as the extension to call the page. First, I will add a class that implements the IHTTPHandler class as below.
The IsReusable() and ProcessRequest(HttpContext context) methods need to be implemented as part of implementing the interface. The HttpContext class contains reference to the Request and Response objects. To send custom html as the response, another method Html() is written that return some html content as string.
To be able to use this code and use .example as the file extension, the <system.web> section of web.config file needs to be updated. The code is shown below.
When any page with file name, for example, example.example is called on the browser, custom html is returned as defined in ProcessRequest method in CustomHandler class.