I am using SQL Server Management Studio. In my table there is a column with datatype varbinary(max). I have successfully uploaded the file of specific format(pdf,xlx,jp or png) to my table. But now I am facing difficulty to retrieve it. I am using ASP.NET. I need to make a controller which can get the file from database through LINQ and make it download to the user's computer.
How to retrieve file from Database of any type(pdf,xlx,jp or png) and make it download-able on webpage?
455 Views Asked by Anirudh Singh Rawat At
1
There are 1 best solutions below
Related Questions in ASP.NET
- Implementing Azure AD B2C Authentication in .NET 8 Blazor Project (RenderMode: InteractiveAuto)
- Azure Application Insights Not Displaying Custom Logs for Azure Functions with .NET 8
- IIS Rewrite Module exclude bots but allow GoogleBot
- Angular 16 sending null values to API
- I am the domain admin, newbie, how do I connect youtube.com on my domain?
- Dropdown list showing SQLServer2005SQLBrowserUser$DONSERVER instead of Active Directory group name in ASP.NET MVC C#
- ASP.NET Identity, Losing Ability to Login until Application Pool Recycles
- How to unprotect ASP.NET FormAuthentication cookie
- How does it work using ASP.NET FormAuthentication
- What is the purpose of a completely standalone 'this'?
- Is there a way to read .csproj PropertyGroup variable in c#
- MSBuild trying to copy different dll with similar name into project sporadically
- Minimizing IdentityServer4 Round Trips in Microservice Architecture with Ocelot
- Azure AD guest account in web app authentication user claims data
- Receiving 400 bad request on post when customer auth handler is used
Related Questions in SQL-SERVER
- Dynamic query creation with Array like implementation
- 'pyodbc.Cursor' object has no attribute 'callproc', mssql with django
- Driver com.microsoft.sqlserver.jdbc.SQLServerDriver claims to not accept jdbcUrl, ${SPRING_DATASOURCE_URL}: GitHub Actions
- PHP Laravel SQLServer could not find driver
- Upsert huge amount of data by EFCore.BulkExtensions
- How to locate relevant tables or columns in a SQL Server database
- Cannot delete SQL datafile (.mdf) as its currently in use
- Writing query in CTE returning the wrong output
- Group By Sum and without Group by sum Amount is different
- plan_handle is always different for each query in SQL Server Cache
- Adding a different string to a table fails
- The specified data type in the EF modelBuilder doesn't correspond to the one that is created
- SQL71561: SqlComputedColumn: When column selected
- How to Solve Error Associated with Trusted Authority
- SQL Server Data Model and Insert Performance
Related Questions in ASP.NET-MVC
- I have a problem outputing the roles on the page ListRoles.cshtml
- Dropdown list showing SQLServer2005SQLBrowserUser$DONSERVER instead of Active Directory group name in ASP.NET MVC C#
- Hosting ASP.NET MVC application on IIS web server using Windows 2019 server
- How to display only department fields associated with a selected department in student automation system?
- How to send select input data for form submission?
- Multi level project reference using dll
- How to upload file to Onedrive using ASP.NET MVC?
- ASP.NET MVC web app looping between fields only on some devices
- Is there any automatic job to load AD-groups?
- How to restrict admin js files to download
- Download PDF in ASP.NET MVC application
- How to add bootstrap theme/example into ASP.NET MVC 5?
- Web API works with Windows authentication enabled when consumed via Swagger but throws an unauthorized issue when accessed through web app
- ASP.Net Core 7.0 Web App (Model-View-Controller) ErrorViewModel OnGet OnPost do not get called or executed
- OAuth 2.0 keep getting Authorization has been denied for this request
Related Questions in LINQ
- How to filter properties of derived classes in a DbContext with dynamic LINQ
- Query (or LINQ in Entity Framework) for getting user's rank
- How to return Inserted Updated Id in a Merge query
- Equivalent of LISTAGG in LINQ doesn't work
- Getting attribute from xml and printing it error
- Linq Grouping and workaround data entry errors in groups
- 'Unable to cast the type 'System.Guid' to type 'System.Object'. LINQ to Entities only supports casting EDM primitive or enumeration types.'
- linq issue accessing deep xml data
- OrderBy with lambda?
- Evaluating logical expressions recognized by ANTLR using the System.Linq.Expressions namespace
- Implementing List<T>, why wont it cast back to MyList after LINQ ? (Unable to cast object of type 'WhereListIterator`1)
- Linq GroupBy and Filter
- LINQ group by date and time
- How do I achieve client-side evaluation in LINQ?
- How do I create a Linq query that will return multiple complex properties in a sub property of a table?
Related Questions in VARBINARYMAX
- Able to initially retrieve string from varbinary but not able to retrieve it again after setting it from ascii file?
- Add default value to a Varbinary column in SQL Server
- Insert varbinary using nanodbc library
- Storing and Retrieving PDF Files in Azure SQL Managed Instance
- Varbinary(max) too large to read in ASP.NET Core
- Convert varbinary(max) column from Azure SQL database into local image file
- When I write a string to an image field in SQL it gets saved in UTF-16 LE encoding and I need it to be UTF-8
- How to convert varbinary(max) to base64 SQL Server 2014
- Add a Word docx as a DEFAULT to a varbinary(max) column
- yii2 and mssql insert varbinary into model
- How to insert a pdf or image to SQL server
- Trying to update SQL Blob in table (Varbinary(max) data type in database
- Displaying varbinary image from SQL database in Access 365 front end
- VarBinary(max) to list of integers
- BCP utility 13.0 bug with varbinary(max)
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
There are bunch of tutorials on this problem containing time-taking answers which may or may not deal with the current scenario. So here is what you need to do in steps:
Then use
FormDatato attach the file (variable) to the form.The formData work as a key:value pair when we send data to controller. Now send the data to controller through ajax:
Now in controller mentioned in URL, make sure it contains the parameter with the same name file as mentioned in
formData.append("file",file);. The datatype of the file will beHttpPostedFileBase. The controller will look like this:Now to retrieve file from database by creating file on server and then sending that file further to the user by providing the path of file on server.