0

現在、webforms プロジェクトで作業していますが、generichandler.ashx への ajax 呼び出しを行うときに、.net mvc パターンと同様のルーティングが必要です。現在、私のコードは次のようになっています。

public class GenericHandler : BaseView, IHttpHandler, IRequiresSessionState
{
    public void ProcessRequest(HttpContext context)
    {
        HttpContext.Current.Response.ContentType = "application/json";
        HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;

        if (HttpContext.Current.Request["Action"] != null)
        {
            switch (HttpContext.Current.Request["Action"])
            {
                case "Foo":
                    Foo();
                    break;
                    //etc...

うまくいきますが、かなり醜い解決策だと思います。ですから、ここであなたの助けが必要です。ルーティングを改善する方法についての提案は大歓迎です。おそらくリクエストで動的関数名が渡されましたか?

4

0 に答える 0