Pur*_*ish 6 vb.net asp.net iis
我在Intranet站点中的几个地方使用Web方法正在工作并且它们工作正常,但是每次我尝试访问Web方法时,一个页面经常抛出HTTP 401错误.
我不知道如何解决这个问题,我已经尝试用Web方法评论所有内容,并且仍然得到401错误,即使是基本的数据库连接只是SELECT 1在我用分析器观看数据库时没有显示.
我的web.config对于Intranet中的所有页面都是相同的,我看不到我的ASP.Net页面与Web方法工作的页面有任何差异.
任何人都可以告诉我为什么这可能只发生在这个页面而不是其他人?还有我如何解决这个问题?
ASP.Net代码(从按钮的OnClientClick调用)
function SendEmails()
{
var Grid = document.getElementById("instructorGrid");
var mailBody = document.getElementById("txtMailBody");
var ddlDutyPeriod = document.getElementById("DDL_DutyPeriods");
var cell = Grid.rows[i].cells;
var HTML = cell[0].innerHTML;
var chkBox = cell[5].innerHTML;
PageMethods.TestMethod()
}
Run Code Online (Sandbox Code Playgroud)
脚本管理器
<asp:ScriptManager ID="ScriptManager1"
runat="server"
EnableScriptGlobalization="true"
EnablePageMethods="true"
EnableScriptLocalization="true">
</asp:ScriptManager>
Run Code Online (Sandbox Code Playgroud)
VB.Net代码
<System.Web.Services.WebMethod()>
Public Shared Sub TestMethod()
'Dim conn1 As New SqlConnection(ConfigurationManager.ConnectionStrings("Blueprint").ToString())
'Dim cmd2 As New SqlCommand
'cmd2.CommandType = CommandType.Text
'cmd2.CommandText = "SELECT 1"
'cmd2.Connection = conn1
'conn1.Open()
'cmd2.ExecuteNonQuery()
'conn1.Close()
End Sub
Run Code Online (Sandbox Code Playgroud)
小提琴手的结果
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Not Authorized</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Not Authorized</h2>
<hr><p>HTTP Error 401. The requested resource requires user authentication.</p>
</BODY></HTML>
Run Code Online (Sandbox Code Playgroud)
更新:
我已经尝试在这个链接http://support.microsoft.com/kb/306158中使用模拟用户代码,但我不能这样做,因为该方法是一个web方法.
我也尝试在web.config中添加对我的登录页面的匿名访问,如下所示,但这也没有帮助
虽然可能性不大,但你的 Web.Config 中有这个吗?
<system.web.extensions>
<scripting>
<webServices>
<authenticationService enabled="true" />
</webServices>
</scripting>
</system.web.extensions>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1387 次 |
| 最近记录: |