I recently downloaded Visual Studio 2012 for web(express edition) and I am creating a simple asp .net empty web site. I am retreiving the data from mysql database by using Websockets. For that i want to add .ashx file to my solution but when i am hitting add new item it is not giving me the option to add .ashx file(handler file).
edited-- all the option i am getting for adding a new file are Text File html page style sheet xml file xml schema xslt file sql file
The item is listed as "Generic Handler"
It is also just a file type and if you can't add it you can just add an html page. When adding call it something like Handler.ashx.
Then copy and paste the default handler code, and rebuild.
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable {
get {
return false;
}
}
}
Visual Sudio will stop yelling at you and underlining things once you rebuild and close/reopen the new .ashx file.
If it still has issues something is wacked up somewhere. If you have older versions of studio see if it will let you create a .ashx there. Then maybe import it?
EDIT-Visual Studio Command Prompt for Missing Templates
You can run Visual Studio Command promt and look into `devenv' if you are missing templates but have them in the templates directories. They may just need to be installed.
devenv /installvstemplates
Try to add "Web">"C#">"Generic Handler" file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With