Recently, Microsoft launched a new version of Visual Studio which is VS 2014 (VNext). Although I am not always happy with such a quick versions by Microsoft but this time it will a great NEWS and give a strong competition to all the open source competitors.
VNext is a open source. With VNext you will get MVC 6 , .NET framework 4.5.3.
You can download the VNext from following link
In VNext you will found a lot change. Major highlights
1) Project solution change
2) New configuration file
3) New dependency (reference) utility
5) web.Config removed
7) Next Generation “JIT”
There are many more things which we will discuss later on.
Till Enjoy VNext.
Thanks & Best Regards,
It’s almost 2 week that I did not post any article friends sorry for that busy in some other high priority task. Today we will work on how to download a file with asp.net which exists in database.
So friends here we go.
Let us suppose we have a table of document in which we keep document in binary format. Suppose the table structure is as follows.
Now what we have to do is by passing just lngId we will download the file or open in browser.
The code for doing this so simple.
Which I mention below
Dim sqlcon as New Sqlconnection(strConnectionString)
Dim ds as new dataset
Dim sqlcmd as new sqlcommand
Sqlcmd.commandType = commandtype.storeprocedure
Sqlcmd.commandtext = “proc_getDocumentById”
Sqlcmd.parameters.add(“@lngId”,intDocumentId) ‘int documented is lngID of document
Dim sda as new sqldataAdapter
Sda.selectCommand = sqlcmd
If ds Is Nothing = False AndAlso ds.tables(0).rows.count >0 Then
Dim dr As dataRow = ds.tables(0).Rows(0)
Context.Response.ContentType = dr (“DOCTYPE”).ToString()
Dim intLength As Integer = DirectCast(dr (“DOCDATA”), Byte()).Length()
Context.Response.AddHeader(“Content-Disposition”, “inline;filename=” & dr (“DOCNAME”))
‘ Context.Response.AddHeader(“Content-Disposition”, “attachment;filename=” & dr (“DOCNAME”))
Context.Response.CacheControl = “public”
dR = nothing
Ds = nothing
Sqlcmd = nothing
Sqlcon = nothing
Sda = nothing
Now the main important point here is content – disposition, and content type
Content type is basically type of content which we are going to download like, JPEG, word, text, etc
And content disposition describe that whether you want download the file or open in browser.
If you want to open in browser then use “inline” and if you want to download then use “attachment” in disposition setting.
So in this way we easily download and kind of file.
If you feel any kind of suggestion, discussions feel free to contact.
Thanks & Esteemed Regards