2014-10-18 69 views

回答

0

我对第一个问题的答案。 您必须在“Session [data]”中存储一些有用的数据,并且不要从客户端发送它。

public ActionResult Index() 
    { 
     try 
     { 
      if (WebSecurity.IsAuthenticated) 
      { 
       String ContractID_string = Session["ContractID"].ToString(); 
       if(ContractID_string!="0") 

另外,不要在linq或sqlQuery中使用客户端的一些字符串输入值而不进行检查。

的最佳方式使用

控制

[HttpPost] 
    [ValidateAntiForgeryToken] 
public ActionResult _SaveMail(Email_Options Mail) 

鉴于

 @using (Ajax.BeginForm("_SaveMail", "Contract", Model, 
     new AjaxOptions 
     { 
      UpdateTargetId = "Email_Options", 
      OnFailure = "alert('errr')", 
      OnSuccess = "DeleteErrorMessage('#Form_"+ViewBag.Contract_part+"')" 
     }, htmlAttributes: new { id = "Form_"+ViewBag.Contract_part})) 
    { 
     @Html.AntiForgeryToken() 
     @Html.ValidationSummary() 
     <table id="Email_Options"> 
      <tbody> 
       <tr> 
        <th>@Html.LabelFor(m => Model.Email, new { style = "font-size:1.05em;" })</th> 
        <th> 
         @Html.HiddenFor(m => Model.ContractID) 
         @Html.EditorFor(m => Model.Email) 
         @Html.ValidationMessageFor(m => Model.Email) 
         <button style="font-size:1em; margin:0px; padding:0;" type="submit">Сохранить</button> 
        </th> 
       </tr> 
       <tr> 
        <th>@Html.LabelFor(m => Model.SendToEmail, new { @class = "checkbox" })</th> 
        <th>@Html.CheckBoxFor(m => Model.SendToEmail)</th> 
       </tr> 
       <tr> 
        <th>@Html.LabelFor(m => Model.SentToHome, new { @class = "checkbox" })</th> 
        <th>@Html.CheckBoxFor(m => Model.SentToHome)</th> 
       </tr> 
       <tr> 
        <th>@Html.LabelFor(m => Model.Print, new { @class = "checkbox" })</th> 
        <th>@Html.CheckBoxFor(m => Model.Print)</th> 
       </tr> 
      </tbody> 
     </table> 
    }