单击

时间:2016-06-17 10:36:23

标签: c# asp.net iis

所以我在此网址“http://192.168.0.23:8083/

中托管了一个登录页面

我将登录页面设置为启动页面,其中包含web.config中的代码,如此

<defaultDocument>
  <files>
    <clear />
    <add value="Login.aspx"/>
  </files>
</defaultDocument>

登录页面是简单的AD身份验证:

 using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "192.168.0.12"))
        {
            // validate the credentials
            isValid = pc.ValidateCredentials(Login1.UserName.ToString(), Login1.Password.ToString());
            if (isValid == true)
            {
                Application["logimi"] = Login1.UserName.ToString();
                Server.Transfer("Default.aspx");
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Perdoruesi ose fjalekalimi jane gabim!')", true);
            }
        }

因此,在成功登录后,我使用Server.Transfer(“Default.aspx”);转到另一页。

第二页中插入按钮的代码:

string selectedValue = RadioButtonList1.SelectedValue;

        string ConnectionString = ConfigurationManager.ConnectionStrings["NOA_VotingConnectionString"].ConnectionString;
        using (SqlConnection con = new SqlConnection(ConnectionString))
        {
            SqlCommand cmd = con.CreateCommand();
            cmd.CommandText = "UPDATE Candidates SET Votes = Votes + 1 WHERE Id = @Id";
            cmd.Parameters.AddWithValue("@id", selectedValue);

            con.Open();

            cmd.ExecuteNonQuery();

            con.Close();

            SqlCommand cmd2 = con.CreateCommand();
            cmd2.CommandText = "INSERT INTO Voters(IPofUser) VALUES(@IP)";
            cmd2.Parameters.AddWithValue("@IP", logimi);

            con.Open();

            cmd2.ExecuteNonQuery();

            con.Close();

        }
        RadioButtonList1.Visible = false;
        Button1.Visible = false;
        Label1.Text = "Vota juaj u ruajt. Faleminderit.";

页面已成功打开。这里我有一个在SQL中插入内容的按钮但是当我点击它时,它会将网址从“http://192.168.0.23:8083/”更改为“http://192.168.0.23:8083/Default”,并说404错误。

我该如何避免这种情况?我在搜索时发疯了。

伙计们我注意到了什么。在本地测试中,如果我输入http://localhost:59901/Default,则转到Default.aspx 但是在IIS上如果输入相应的网址http://192.168.0.23:8083/Default则会显示404。

也许这与IIS有关,我是否必须在那里指定一些内容?

谢谢

0 个答案:

没有答案