追加:
AttributeRoutingへの変換に失敗したプロジェクトをダウンロードします。
ホームページのメッセージが「新着メールなし」の間で変わると、プロジェクトは正しく実行されます。と「あなたはメールを持っています!」。現在のエラー状態では、そのメッセージは変更されません。
javascriptコンソールのエラーが表示されます。
ブラウザで/Checkemailに直接移動すると、404エラーが発生します。
元の投稿:
これは、 AttributeRouting(最新のv3.4.1を使用)に関する質問です。
私はGET[""]
次のコードにフックしようとしています。
[GET("")]
404が表示されます-リソースが見つかりません。
[GET("CheckEmail")]
私は405を取得します-メソッドは許可されていません。
このプロジェクトをAttributeRouting:ソースコードに変換しようとしています。checkemailアクションは、私が失敗しているところです。
このメソッドは、「 ajaxロングポーリング」手法の一部としての非同期メソッドです。
私の悲惨な試みについてコメントした次のことがあります:
public class CheckEmailController : AsyncController
{
//
// GET: /CheckEmail/
//tried [GET("")]
//tried [GET("CheckEmail")]
public void IndexAsync()
{
AsyncManager.OutstandingOperations.Increment();
MyAsyncEmailChecker.CheckForEmailAsync(hasEmail =>
{
AsyncManager.Parameters["hasEmail"] = hasEmail;
AsyncManager.OutstandingOperations.Decrement();
});
}
private class IndexResponse
{
public bool d { get; set; }
}
public JsonResult IndexCompleted(bool hasEmail)
{
return this.Json(new IndexResponse() { d = hasEmail });
}
}
Global.asax.cs-私のすべてのARプロジェクトについて
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
}
ありがとうございました