Being a web developer, you must have worked one or more times on providing feature for downloading a file. If not, you’ll work in near future. Anyways let’s discuss a scenario.
Normally, we see that when we click on a link of the file to download that link opens up in the browser. Actually when we click on the link, request is sent to web server, and server returns the content to the client. Based on the file name extension, browser decides the type of content and accordingly, if browser has a capability to load the file on browser that it shows it in the browser. If browser is not able to display on the browser the shows the download file dialog box to save it. You may see different behavior in different browser because some browser may able to show it on browser and other may show the download dialog box. But you can save it via browser save as option if it is rendered on browser.
But How to forcefully show the save as dialog to the user?
As we already discussed that when we click the on any link then based on the browser capability the browser shows the dialog box or open it in the browser itself. But to show the save as dialog every time (for every type of file) we need to to tell browser that this is an attachment. For this we need to add a Content-Disposition Header in the response. This should be as
You can write the code to download the file many ways. But if you want to download it using the browser’s download dialog box then we need to add Content-Disposition Header. We can write the code for downloading a file as
Once you add the Content-Disposition header, the file will always be downloaded. As the behavior of browsers varies as Firefox shows a save as dialog, Internet Explorer (v11) prompts at the bottom side of browser, while Google chrome downloads it without prompting but in any case file will be downloaded.
Thanks for reading the post.
In this post, We are going to talk a library that you guys must have seen in latest version of ASP.NET (4.5) and ASP.NET MVC (4.0). So first let’s first understand,
What is WebGrease?
This is another post on Authentication for ASP.NET applications. In one of my last posts, I talked about setting up authentication mode as Windows in web.config and Enabling/Disabling windows authentication at IIS. You can access that post from the below link.
Looking into Windows authentication at Web.config and at IIS
I have seen many confusion around setting authentication mode as windows in web.config and enabling Windows authentication at IIS.
First thing that there is no relation between setting authentication mode as windows at web.config and enabling/disabling (Integrated)Windows Authentication at IIS.
I have seen many questions in the forums that how can we bind the CheckBox list from the database via Ajax. There could be many ways to do in an ASP.NET but I will be using the one of the most efficient options available .
In this post, I’ll be using jQuery Ajax to get the data from the server (that will be fetch the data from database) and then will create the CheckBox list dynamically.
There are several phases of a Application . It does not end with developing the application and deploying it on production servers. Other most important part, any problem surfaces after the deployment, how quickly the problem can be be resolved and according to severity of the issue (if required) a patch can be deployed on production. Apart from this, we also want to get notified on all the issues occurred on production and accordingly analyze and take care in future releases. We can also log other details that could be useful to check the status of Application.
Yes it does!!
But let’s first understand that what is a proxy? As we already know whenever we have to use any web service or WCF service, we need to create proxy of that service and with the help of proxy, we use the functionalists provided by the web/WCF service. Proxy acts a intermediary between the client of the service and the actual service. Proxy provides a simple interface to the consumer of service and all the intricacies like creating a connection, creating and sending the request, getting the response etc is handled by the proxy itself.
This event is special at this time as the founder of C# Corner, Mahesh Chand (8 times Microsoft MVP) will join us and take two sessions on Enterprise Architecture
C# corner Delhi chapter is hosting next event on 22nd June at Noida. This time we’ll be talking on latest hot .NET technologies like ASP.NET MVC, Linq and Web API. If you are interested in the above technologies then you are welcome to join us. This is totally free event. the detailed agenda is
Its a little gap in between my third and fourth part, anyways I am going to write 4th part of the series. First you can read my earlier parts from the link below.
As if you have read my earlier posts in the series, you can visualize that in my first post I discussed about the Idea about Claim based authentication, basics and various components of Claim based authentication.