【发布时间】:2018-01-16 06:26:14
【问题描述】:
我做了很多搜索,我发现的一切都表明我的设置应该可以工作(似乎没有人有我的确切问题,我似乎没有其他人的问题)。
我以前作为实习生做过这件事,但我没有设置,现在我正在尝试从头开始做所有事情,尽可能接近我以前的做法,并在我前进的过程中学习。我只是想从我的网络方法中得到答复。一旦我开始工作,我就可以继续前进。让我知道你们的想法......
产品.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Product</title>
<link href="Content/styles.css" rel="stylesheet" />
<!-- Bootstrap -->
<link href="Content/bootstrap.css" rel="stylesheet" />
<link href="Content/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- Calendar -->
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
</head>
<body>
...
<div class="buttonsInline">
<button class="btn btn-info btn-lg" onclick='Test()' style="float:none">Alert</button>
</div>
...
</body>
</html>
<script>
function getVendorSystem() {
var system = sessionStorage.getItem('setSystem');
var vendor = sessionStorage.getItem('setVendor');
alert("System: " + system + "\nVendor: " + vendor);
}
function Test() {
$.ajax({
method: 'post',
url: "WebNet.aspx/MSG",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
async: "true",
cache: "false",
success: function Succeed() {
alert("SUCCESS!");
},
error: function Error() {
alert("An Error Occured.")
}
});
}
</script>
WebNet.aspx.vb
Imports System.Web.Services
Imports System.Data.SqlClient
Public Class WebNet
Inherits System.Web.UI.Page
<WebMethod()>
Public Shared Function MSG()
MsgBox("Updated")
'Dim sqlConnection1 As New SqlConnection("Your Connection String")
'Dim cmd As New SqlCommand
'Dim reader As SqlDataReader
'cmd.CommandText = "SELECT * FROM Customers"
'cmd.CommandType = CommandType.Text
'cmd.Connection = sqlConnection1
'sqlConnection1.Open()
'reader = cmd.ExecuteReader()
' Data is accessible through the DataReader object here.
'sqlConnection1.Close()
Return 0
End Function
End Class
WebNet.aspx
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site1.Master" CodeBehind="WebNet.aspx.vb" Inherits="WebApplication1.WebNet" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
我收到错误 404。对 URL 使用 Action 会给我错误 400。
只需输入 URL http://localhost:63787/WebNet.aspx/MSG 就会给我 404,但 http://localhost:63787/WebNet.aspx 很好,应该如此。
【问题讨论】:
-
我想,这不是我写的代码。我花了 3 天时间检查它,我当然不会跳……但这似乎暂时解决了它。 stackoverflow.com/questions/29860304/…
标签: jquery ajax vb.net http-status-code-404 http-status-code-400