回发失败在默认文档 [英] Postback Fails On Default Document

查看:141
本文介绍了回发失败在默认文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我创建了一个Web应用程序(而不是网站)与ASP.NET(C#)和它编译于VS13环境就好了。但是,当我将其发布在IIS上默认文档回发失败。默认文档被称为LoginPage.aspx。 ASP;当我点击&LT很快:按钮> 运行我的code的背后,它是所有刷新页面。该项目已发表在我的本地127.0.0.1 IP地址暂且。

So I've created a Web Application (not Web Site) with ASP.NET (C#) and it compiles just fine in the VS13 environment. But when I publish it on IIS, the Postback on the Default Document fails. The Default Document is called LoginPage.aspx. As soon as I click the <asp:Button> to run my code behind, all it does is refresh the page. This project has been published on my local 127.0.0.1 IP address for the time being.

我知道这已经证明的问题,但我已经尝试了许多解决方案,并在决议还没有来。一些解决方案我已经尝试:

I know this has been a documented issue, but I've tried many solutions and have not come across a resolution. Some solutions I have attempted:


  • 创建一个全新的Web应用程序以最少code试图访问任何回传,但没有成功。

  • 我试过没有成功在这里psented第一个解决方案$ P $:<一href=\"http://stackoverflow.com/a/7367076/4204026\">http://stackoverflow.com/a/7367076/4204026

我也试过URL映射:

<urlMappings>
    <add url="~/login" mappedUrl="~/Views/LoginPage.aspx" />
    <add url="~/login/" mappedUrl="~/Views/LoginPage.aspx" />
</urlMappings>

我是诚实的茫然,这里发生了什么。有一件事我没有通知是当应用程序被通过Visual Studio运行时,&LT;形式&GT; 在LoginPage.aspx标记出现在Chrome中为:

I'm honestly at a loss as to what's happening here. One thing I did notice is when the application is being run through Visual Studio, the <form> tag on the LoginPage.aspx appears in Chrome as:

<form method="post" action="LoginPage" id="ct101" class=".myForm">

通过IIS:

<form method="post" action="./" id="ct101" class=".myForm">

不知道这是一个问题,无论是。我试着硬编码动作登录来看看会发生什么,它并重定向到正确的页面,但因为怀疑是回发被解雇了 - 我的会话变量返回null,并没有使用查询字符串

Not sure if that's a problem either. I tried hard-coding the action to login to see what would happen and it does redirect to the correct page, but as suspected no Postback was fired - My Session variable returned null and no query string was used.

下面是相关LoginPage.aspx前端code(修剪了一堆不相关的HTML):

Here's the related LoginPage.aspx front-end code (trimmed out a bunch of unrelated HTML):

<%@ Page Title="DREW KENNEDY | WELCOME" Language="C#" MasterPageFile="Site.Master" AutoEventWireup="true" CodeBehind="LoginPage.aspx.cs" Inherits="MyMedia.Views.LoginPage" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <!-- form is located on Site.Master -->
    <asp:Button OnClick="LoginBtn_Click" CssClass="login" runat="server" name="submit" Text="Sign In" />
</asp:Content>

而LoginBtn_Click方法LoginPage.aspx.cs:

And the LoginBtn_Click method in LoginPage.aspx.cs:

protected void LoginBtn_Click(object sender, EventArgs e) {
    //Tried the following line while commenting out everything else to make sure Postback is being ignored
    //Response.Write("<script>alert('Test');</script>");
        try {
            AbstractPersistenceDecorator decorator = new PersistenceDecorator();
            string uname = username.Text.Trim();//username is a TextBox Control
            string pass = password.Text.Trim();//password is a TextBox control

            bool isCookieRequested = CheckBox.Checked;
            if (decorator.authenticate(uname, pass)) {//calling SQL Server for authentication
                User AuthenticatedUser = (User)Session["User"] ?? decorator.getUserInfo(uname);

                if (Session["User"] == null) Session["User"] = AuthenticatedUser;

                if (isCookieRequested) {
                    HttpCookie cookie = new HttpCookie("username", AuthenticatedUser.Username);
                    cookie.Expires.AddDays(7);
                    Response.Cookies.Add(cookie);
                } else {
                    Session.Timeout = 15;
                }
                Thread.Sleep(1600);
                //string redirect = string.Format("dashboard?username={0}", AuthenticatedUser.Username);
                Response.Redirect("dashboard?username=" + AuthenticatedUser.Username);
            }
        } catch (Exception ex) {
            //who cares?
        }
    }

信息的最后部分:

Final pieces of info:


  • 运行IIS 8.0

  • 4.5框架创建的应用程序,应用程序池也是4.5框架

  • 我已确保ASP.NET安装在IIS

  • 我有在Global.asax文件URL重写,虽然我不知道这是任何关系(我怎么没看到)。

  • 我没有Default.aspx页

编辑:


  • 只需通过IE11和FF 127.0.0.1具有相同的结果测试项目中。

编辑#2:

其他的事情我都没有成功尝试:

Additional things I have tried with no success:


  • 我试着删除我的URL重写

  • 我尝试添加一个空的URL重写规则,即(空URL,,〜/查看/ LoginPage.aspx)

  • I tried removing my URL Rewriting
  • I tried adding an empty URL Rewrite rule, i.e. ("Empty URL", "", "~/Views/LoginPage.aspx")

其他注意事项:


  • 我不使用Telerik的

  • 我不使用ISAPI

  • 在Visual Studio中的项目设置为调试,而不是发布

  • I do not use Telerik
  • I do not use ISAPI
  • The project in Visual Studio was set to debug and not release

推荐答案

我的,因为我已经找到了答案在OP没有给予足够的信息道歉。事实证明,它没有什么做ASP.NET,而是 SQL服务器。我扯下了code裸露,一次加回一件code,并剥离了所有的异常处理后,我通过IIS发现 IIS APPPOOL \\ .NET其中Vx.x 没有权限来访问数据库。

I apologize for not giving enough information in the OP as I have found the answer. It turns out it had nothing to do with ASP.NET, but rather SQL Server. I stripped the code bare and after adding back one piece of code at a time and stripping away all exception handling, I found through IIS that IIS APPPOOL\.NET vX.X did not have permissions to access the database.

我不得不做的是:


  • 在MSQLSM,添加一个新的登录 IIS APPPOOL \\ .NET 4.5版

  • In MSQLSM, add a new Login for IIS APPPOOL\.NET v4.5

另外,我发现,它需要正确的权限收到以下异常后执行某些命令:

Further on, I found out that it needed the correct permissions to perform certain commands after receiving the following exception:

的SELECT权限被拒绝对象'X',数据库'X',架构'DBO

The SELECT permission was denied on the object 'X', database 'X', schema 'dbo'

<一个href=\"http://stackoverflow.com/questions/1196793/the-select-permission-was-denied-on-the-object-address-database-cnet-85731\">This解决了这里


  • 给新的登录适当的访问。登录属性>用户映射>检查的db_datareader 公共

  • Give that new Login the proper access. Login Properties > User Mapping > checking db_datareader and public.

背后的code现在执行。它仍然留下为什么它禁止任何回发的问题,即使我在code删除任何SQL连接后面。很奇怪的。

The code behind now executes. It still leaves the question why it was prohibiting any Postbacks, even if I removed any SQL Connectivity in the code behind. Very strange.

无论如何,感谢那些谁帮助。

Anyway, thanks to those who helped.

这篇关于回发失败在默认文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆