2017-03-23 5 views
0

私はasp.net mvc4で作業しています。ポストメソッドin asp.net mvc4他のページへ

Iは、コントローラを有する:

public class ExtendedProfileController : ProfileController 
    { 

     protected override void RegisterSystemRoutes(SanaRouteCollection routes) 
     { 
      routes.MapSystemPageRoute("Profile", "BalieNr", "BalieNr", "Profile/BalieNr"); 

      base.RegisterSystemRoutes(routes); 
     } 

     [HttpGet] 
     public ActionResult Hallo() 
     { 
      return View(); 

     } 




     [HttpGet] 
     public ActionResult BalieNr() 
     { 

      return View(); 


     } 


     [HttpPost] 
     [ValidateAntiForgeryToken] 
     public ActionResult BalieNr(IEntityListLoadOptions options, string accountID, ExtendedSalesAgentInfoModel model /*string accountId, ShopAccountType accountType,Customer.ICustomerListLoadOptions hallo*/) 
     { 

      var salesAgent = CommerceFramework.ShopAccounts.GetShopAccounts(options); 

      foreach (var item in salesAgent) 
      { 
       if (item.ShopAccountType == ShopAccountType.SalesAgent) 
       { 
        if (item.ReferenceId.Contains("DB")) 
        { 
         Console.WriteLine("true"); 
        } 

        var customer = CommerceFrameworkBase.SalesPersons.GetSalesPerson(accountID); 
        Console.WriteLine(accountID); 

       } 
       else 
        Console.WriteLine("false"); 
      } 

      Console.WriteLine(salesAgent); 




      return View(); 
     } 




    } 

主な方法であるBalieNr方法。

だから私はまた、このような見解を持っている:

@{ 

    Layout = LayoutPaths.General; 
} 

@model Sana.Commerce.Customization.Account.ExtendedSalesAgentInfoModel 

<div class="semicolumn"> 
    @*<div class="text">@Sana.RichText("Login_IntroductionText", makeImagesResponsive: true)</div>*@ 
    <div class="form-holder"> 
     @using (Html.BeginForm("BalieNr", "ExtendedProfileController", FormMethod.Post)) 
     { 
      @Html.AntiForgeryToken() 

      <table> 
       <tr> 
        <th> 
         @Html.DisplayNameFor(model => model.Baliecode) 
        </th> 
        <th></th> 
       </tr> 

       <tr> 
        <td> 
         @Html.TextBoxFor(modelItem => modelItem.Baliecode) 
        </td> 

       </tr> 


      </table> 
      <div class="form-row"> 


       @*@Sana.SubmitButton("Login", "btn btn-medium btn-login")*@ 
       <input type="submit" value="Login" /> 
      </div> 
     } 
    </div> 
    <div> 

    </div> 
</div> 

だから私はアクションメソッドとコントローラーの名前を定義します。

しかし、私がポストをすると、コントローラーの私のポストアクションメソッド - BalieNrに行きません。しかし、このリンクに行く:

http://localhost:5923/sitemap.xml 

私はポストメソッドBalieNrにブレークポイントを置く場合。それはそのメソッドをヒットしません。

だから、それを解決する方法は、それがポストメソッドに当たるようにBalieNr?まだ

@using (Html.BeginForm("BalieNr", "ExtendedProfile", FormMethod.Post, new { enctype = "multipart/form-data" })) 
     { 
      @Html.AntiForgeryToken() 

      <table> 
       <tr> 
        <th> 
         @Html.DisplayNameFor(model => model.Baliecode) 
        </th> 
        <th></th> 
       </tr> 

       <tr> 
        <td> 
         @Html.TextBoxFor(modelItem => modelItem.Baliecode) 
        </td> 

       </tr> 


      </table> 
      <div class="form-row"> 


       @*@Sana.SubmitButton("Login", "btn btn-medium btn-login")*@ 
       <input type="submit" value="Login" /> 
      </div> 
     } 

正しい方法を打つdoesntの:私はこれを行う場合

はあなたに

ありがとうございます。

私はこのようにそれを行っている:

@ {

Layout = LayoutPaths.General; 

}

@model Sana.Commerce.Customization.Account.ExtendedSalesAgentInfoModel

@ * @ Sana.RichText ( "Login_IntroductionText"、makeImagesResponsive:true)* @ @using(Html.BeginForm(htmlAttributes:new {@cl Html.AntiForgeryToken @尻= "フォーム"})){ () Html.DisplayNameFor @(モデル=> model.Baliecode) Html.TextBoxFor(modelItem => modelItem @ .Baliecode)* @サナ@ 。サブミットボタン( "ログイン"、 "BTN BTN-中BTN-ログイン")* }

@今では、POSTメソッドを打つ:)

+0

'(Html.BeginForm( "BalieNr"、 "ExtendedProfile"、FormMethod.Post))を使用して' to 'に'(Html.BeginForm( "BalieNr"、 "ExtendedProfileController"、FormMethod.Post)を使用して変更してください) ' –

+0

あなたの返事のために。投稿を編集します –

+0

あなたが作業しているビューが実際にあなたのActionResultにリンクされていることを確信していますか?あなたのActionResultを右クリックし、 'Go to view'を押してリンクされているかどうかを確認してください。そうでない場合は、ActionResultを右クリックし、 'Add View ..'を押します。 –

答えて

0

これは動作します:

@{ 

    Layout = LayoutPaths.General; 
} 

@model Sana.Commerce.Customization.Account.ExtendedSalesAgentInfoModel 

<div class="semicolumn"> 
    @*<div class="text">@Sana.RichText("Login_IntroductionText", makeImagesResponsive: true)</div>*@ 
    <div class="form-holder"> 
     @using (Html.BeginForm(htmlAttributes: new { @class = "form" })) 
     { 
      @Html.AntiForgeryToken() 

      <table> 
       <tr> 
        <th> 
         @Html.DisplayNameFor(model => model.Baliecode) 
        </th> 
        <th></th> 
       </tr> 

       <tr> 
        <td> 
         @Html.TextBoxFor(modelItem => modelItem.Baliecode) 
        </td> 

       </tr> 


      </table> 
      <div class="form-row"> 


       @*@Sana.SubmitButton("Login", "btn btn-medium btn-login")*@ 
       <input type="submit" value="Login" /> 
      </div> 
     } 
    </div> 
    <div> 

    </div> 
</div> 
関連する問題