In my Global.asax.cs file, I created a Session_Start method:
protected void Session_Start(object sender, EventArgs e)
{
//Get the incoming user's IP address.
var ip = HttpContext.Current.Request.UserHostAddress;
if (Helpers.RedirectHelpers.IpIsWithinBoliviaRange(ip))
{
//Render the bolivia page.
}
else
{
//Render the regular layout page.
}
}
Assuming the code in the IpIsWithinBoliviaRange()
method is already coded and working, how do I redirect the request so the user transparently sees a page I coded up?
Here is a snapshot of the solution so you can get a better picture:
The contents of _Layout.cshtml is what you would expect, nothing out of the ordinary.
On the _BoliviaLayout.cshtml file I've done something different:
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>BOLIVIA PAGE</title>
</head>
<body>
<div>
</div>
</body>
</html>
How can I render this page if someone coming in from Bolivia visits the site? What do I need to do to invoke the rendering of this "view"?