控制台程序项目 调用 web 应用程序中的 ashx
static void Main(string[] args)
{
HttpWebRequest webRequest = null;
StreamReader responseReader = null;
try
{
//ashx Url
string getGscUserUrl = "http://localhost:10881/Handler.ashx";
//加入参数,用于更新请求
string urlHandler = getGscUserUrl + "?id=" + Guid.NewGuid();
webRequest = (HttpWebRequest)HttpWebRequest.Create(urlHandler);
webRequest.Timeout = 3000;//3秒超时
//调用ashx,并取值
responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream());
string currentUserGulid = responseReader.ReadToEnd();
//return currentUserGulid.Trim();
}
catch
{
//return "";
}
ashx中 :
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("fuck your mother");
}
无法调试到ashx中!!!并且抱500错误。。高手进。。咱回事!!!!
你架设iis了没