從C#開始,ASP.net從PHP嘗試轉換我的代碼。嘗試檢索C#.aspx網頁表單中的表單響應
我目前正在嘗試下面的代碼來檢索表單中發佈的數據。
<%@ 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>
但我一直收到「/'應用程序中的服務器錯誤。」
任何人都可以幫忙嗎?
你需要給出更多關於錯誤的更多細節。應該有一個完整的堆棧跟蹤。它說什麼?話雖如此,我想這個問題是因爲'header('Location:MercedesHomepage.html');'是PHP語法,而不是.NET。你會想'Response.Redirect(「MercedesHomepage.html」)'我應該想。 – ADyson