Forms iPost在加载网页时立即激活

Forms iPost在加载网页时立即激活,forms,post,razor,Forms,Post,Razor,我的cshtml网页上有两个表单。一个 @if (WebSecurity.IsAuthenticated) { <text> Hello, <a class="email" href="~/Account/Manage" title="Manage">@WebSecurity.CurrentUserName</a>!

我的cshtml网页上有两个表单。一个

@if (WebSecurity.IsAuthenticated) {
                            <text>
                                Hello, <a class="email" href="~/Account/Manage" title="Manage">@WebSecurity.CurrentUserName</a>!
                                <form id="logoutForm" action="~/Account/Logout" method="post">
                                    @AntiForgery.GetHtml()
                                    <a href="javascript:document.getElementById('logoutForm').submit()">Log out</a>
                                </form>
                            </text>
                        } else {
                            <ul>
                                <!--li><a href="~/Account/Register">Register</a></li-->
                                <li><a href="~/Account/Login">Log in</a></li>
                            </ul>
                        }
@if(WebSecurity.IsAuthenticated){
你好
@AntiForgery.GetHtml()
}否则{
}
第二种形式

  <form action ="" id="query" method="post">  <!--need to search database for a match of medirecord, form is used here-->
      <div data-role="fieldcontain">
                <label for="name">Patient NRIC:&nbsp</label>
                <input type="text" name="nric" id="nric" value=""  />
                </div>  
    <input value="Search" type="submit" data-role="button" data-theme="b"  /><!--if cannot find display error msg else go to patient_hist.cshtml-->
             </form>

患者NRIC:
IsPost事件

if(IsPost)
    {            
        String Nric = Request.Form["nric"];
         //var db = Database.Open("StarterSite");
         //var user = db.QuerySingle("SELECT * FROM Patient WHERE NRIC = @0", Nric);
         var user = "test";
         user = null;
         if(user != null)
         {
            <script type="text/javascript">
                alert("Not a user!");
            </script>
         }
         else
         {
                   <script type="text/javascript">
       alert("Its a user!");
      </script>
         }


    }

    else
    {
           <script type="text/javascript">
       alert("Not a Post");
      </script>
    }    
if(IsPost)
{            
字符串Nric=Request.Form[“Nric”];
//var db=Database.Open(“StarterSite”);
//var user=db.QuerySingle(“从患者中选择*,其中NRIC=@0”,NRIC);
var user=“test”;
user=null;
如果(用户!=null)
{
警报(“不是用户!”);
}
其他的
{
警报(“它是一个用户!”);
}
}
其他的
{
警惕(“不是帖子”);
}    

如果我取出else,单击第二个表单中的按钮,表单将立即刷新,而不会发生任何事情

您希望发生什么?@MikeBrind我希望有一个脚本可以激发我的兴趣。在我看来,最好的办法是一次复制一点页面,并在运行时进行测试。这应该能帮你找到坏的地方。