正在尝试检索C#.aspx web表单中的表单响应
C#,ASP.net的新成员,正在尝试转换我的代码 我目前正在尝试使用以下代码从表单中检索发布的数据正在尝试检索C#.aspx web表单中的表单响应,c#,asp.net,post,C#,Asp.net,Post,C#,ASP.net的新成员,正在尝试转换我的代码 我目前正在尝试使用以下代码从表单中检索发布的数据 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CarPage.aspx.cs" Inherits="Ass2.CarPage"%> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="s
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CarPage.aspx.cs" Inherits="Ass2.CarPage"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<%
If Request.Form["Car"] == "Volvo" then
header('Location:VolvoHomepage.html');End If
If Request.Form["Car"] == "Ford" then
header('Location:FordHomepage.html');End If
If Request.Form["Car"] == "Mercedes" then
header('Location:MercedesHomepage.html');End If
If Request.Form["Car"] == "Audi" then
header('Location:AudiHomepage.html');End If
If Request.Form["Car"] == "Vauxhall" then
header('Location:VauxhallHomepage.html');End If
%>
</body>
</html>
但我一直收到“应用程序“/”中的服务器错误。”
有人能帮忙吗?这句话是说您正在用C语言编码:
但在下面,您将混合使用Visual Basic和PHP语言:
<% If Request.Form["Car"] == "Volvo" then
header('Location:VolvoHomepage.html');End If
%>
是否更清楚?您需要提供有关错误的更多详细信息。应该有一个完整的堆栈跟踪。上面说什么?话虽如此,我想问题是因为
header('Location:MercedesHomepage.html')
是PHP语法,而不是.NET。我想你需要Response.Redirect(“MercedesHomepage.html”)
。
<% if (Request.Form["Car"] == "Volvo") {
// do your thing
}
%>
<myUserControls:VolvoHomepage runat="server" id="_ucVolvo" visible="false" />
<myUserControls:FordHomepage runat="server" id="_ucFord" visible="false" />
...
protected void Page_Load(object sender, eventargs e) {
if (Request.Form["Car"] == "Volvo") _ucVolvo.Visible = true;
else if (Request.Form["Car"] == "Ford") _ucFord.Visible = true;
}