Nata Ermakova
Nata Ermakova

Reputation: 239

How to call .ashx file in 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!

Upvotes: 6

Views: 7420

Answers (1)

Andrei R&#238;nea
Andrei R&#238;nea

Reputation: 20780

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>

Upvotes: 5

Related Questions