I’m trying to query a database from the Application_BeginRequest in my Global.asax file to get my currently 301 from a database instead of pure code.
But i can’t seem to find how to do this, i cant write SqlConnection or similar like i’m used to when i’m about to start a SQL query.
Is it even possible to get this type of code:
if (Request.Url.ToString() == "http://www.mywebsite.com")
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", "http://www.mywebsite.org");
}
to be generated from the database? And if so, how can i do it? I’ve tried to search but i can’t seem to find any solution for my problem. An answer would be highly appreciated!
/Lucas
You have written the right code , you can proceed and implement SQLCommand to fetch data from database
e.g.