Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call .ashx file in MVC?

Tags:

asp.net-mvc

I have .ashx file. How can I call this file in MVC?

Something like this:

 <a href="LoadFile.ashx?id=033">load</a>

Thank you!

like image 814
Nata Ermakova Avatar asked Sep 09 '15 10:09

Nata Ermakova


1 Answers

ASP.NET MVC does not prevent you from adding a typical ASHX handler. For example here's what I did:

  1. Take a new/existing ASP.NET MVC project
  2. Right click the project node and select Add -> New -> Generic Handler
  3. Name the handler "HandleMe.ashx"
  4. Write code in HandleMe.ashx.cs according to what I need the handler to do
  5. Run the project and access the handler URL (in my case http://localhost:2951/HandleMe.ashx) and all is good.

For the link you just need to set it to

<a href="/HandleMe.ashx">click me</a>
like image 92
Andrei Rînea Avatar answered Sep 29 '22 04:09

Andrei Rînea