301 Redirects to asp.net

I just uploaded a new website www.tapasya.co.in . When I tried to access, he showed me a blank page. But when I tried to use the full path to the home page http://www.tapasya.co.in/Web%20Pages/Home.aspx , its work.

I think I have solved a problem that may be occurring . I have to put this page in the root folder in order to access it using www.tapasya.co.in. But I do not want to put this page in the root folder. I searched it on google and some solutions say that I need to do a 301 redirect .

But I do not know how to do this. Please help, thanks in advance.

+3
source share
2 answers

Something like this is implied by 301 redirects:

private void Page_Load(object sender, System.EventArgs e)
{
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location","http://www.aspcode.net/newpage");
}

More details here .

+2
source

If you really want your Pages to be in "Web Pages", add this Default.aspx to the root folder:

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    void Page_Load(object sender, EventArgs e)
    {
        Response.Redirect("Web Pages/Home.aspx");
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <a href="Web Pages/Home.aspx">Redirect</a>
    </form>
</body>
</html>

EDIT: Sorry, my fault! My code gives 302 pace. Redirection. Thomas's code is 301.

+1
source

Source: https://habr.com/ru/post/1732845/


All Articles