1

を使用してRouteTable、自分のサイトにいくつかのルートを登録しています。現在、次のようになっています。

Global.asax

void Application_Start(object sender, EventArgs e)
{    
    RemoteReaderPlugin.Current.AllowRemoteRequest += Current_AllowRemoteRequest;

    RegisterRoutes(RouteTable.Routes);
}

public static void RegisterRoutes(RouteCollection routes)
{
    //routes.Ignore("{resource}.axd/{*pathInfo}");

    //Clan
    routes.MapPageRoute("","Clan/{address}","~/Clan/Default.aspx");
    routes.MapPageRoute("", "Clan/Register", "~/Clan/Register.aspx");
    routes.MapPageRoute("", "Member/GameRanking/{address}", "~/Member/GameRanking.aspx");

    //Member
    routes.MapPageRoute("", "Member/{address}", "~/Member/Default.aspx");
    routes.MapPageRoute("", "Member/Register", "~/Member/Register.aspx");
    routes.MapPageRoute("", "Member/GameRanking/{address}", "~/Member/GameRanking.aspx");

    //Site
    routes.MapPageRoute("", "{address}", "~/{address}.aspx");
    routes.MapPageRoute("", "{address}/{resource}", "~/{address}/{resource}.aspx");
}

これはすべて、ブラウザを に向けると機能しhttp://localhost:27950/OCDB/Defaultます。

しかし、ブラウザを に向けるとhttp://localhost:27950/OCDB/、クリックしたリンクは次のエラーにつながります。

Server Error in '/OCDB' Application.

The HTTP verb POST used to access path '/OCDB/' is not allowed.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: The HTTP verb POST used to access path '/OCDB/' is not allowed.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[HttpException (0x80004005): The HTTP verb POST used to access path '/OCDB/' is not allowed.]
   System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) +2523961
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18034

このエラーを修正する方法はありますか? /Defaultまたは、ブラウザを何かの前に強制します。

4

1 に答える 1

1

この行を置き換えるとどうなりますか :

routes.MapPageRoute("", "{address}", "~/{address}.aspx");

routes.MapPageRoute("", "{address}", "~/{address}.aspx", true, defaults: new RouteValueDictionary { { "address", "default" } });

これが役立つことを願っています

于 2013-01-25T14:48:39.380 に答える