私はWebApiプロジェクトからHandler.ashxをURLなどで呼び出す方法は?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace XXX.XXX.WebApi.Controllers
{
/// <summary>
/// Summary description for Handler1
/// </summary>
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
シンプルOOTBハンドラを持っている私のファイル構造は、URLを介して、このハロー世界の例を呼び出す方法
のですか?
https://msdn.microsoft.com/en-us/library/ms228090.aspx
https://www.codeproject.com/articles/538589/theplustruthplusaboutplushttphandlersplusandpluswe
や他の多くのもののない私は何をしようとした(またはとと)き
私は多くのチュートリアルを経て、常に何かが間違っていた...にApp_Codeフォルダなどのような私の場合は成功です。何か案は?
Web APIプロジェクトにハンドラを追加する理由は何ですか? – Darren
私はashxがファイルを扱うのに適していて、ashxはそのためには最高だと言っています。 –
あなたは幾分技術を混ぜています。本当に、あなたはウェブAPIでファイルを受け入れる方法を知りたがっているように思えます - これはもっと良い質問です - このようにhttp://stackoverflow.com/questions/34168395/how-to-post-and-receive- a-file-with-web-apiハンドラはそれを別のやり方で行いますが(必ずしも簡単ではありませんが)、Web APIプロジェクトでハンドラーではなくコントローラを使用します – Darren