C# Umbraco:检测原产国
我对Umbraco一无所知,有一个预先存在的Umbraco 7/.Net项目,它需要能够检测用户的原产国并重定向。我希望使用以下内容:C# Umbraco:检测原产国,c#,asp.net-mvc,umbraco7,C#,Asp.net Mvc,Umbraco7,我对Umbraco一无所知,有一个预先存在的Umbraco 7/.Net项目,它需要能够检测用户的原产国并重定向。我希望使用以下内容: using System.Globalization; string name = RegionInfo.CurrentRegion.DisplayName; 但是,尽管项目启动到“主”视图,但我看不到任何HomeController,因此我不确定从何开始 任何指点都是非常受欢迎的。这不是翁布拉科能做到的。。您需要查找用户的ip地址,然后根据位置进行重定向。
using System.Globalization;
string name = RegionInfo.CurrentRegion.DisplayName;
但是,尽管项目启动到“主”视图,但我看不到任何HomeController
,因此我不确定从何开始
任何指点都是非常受欢迎的。这不是翁布拉科能做到的。。您需要查找用户的ip地址,然后根据位置进行重定向。Use可以使用如下服务 我建议您采用如下网站结构:
- 主页(只是一个空白页。是否重定向到此处的子页)
- /嗯
- /德
- /太平绅士
- 主页(只是一个空白页。是否重定向到此处的子页)
- /嗯
- /德
- /太平绅士
public class HomePageController : Umbraco.Web.Mvc.RenderMvcController
{
// GET: HomePage
public override ActionResult Index(RenderModel model)
{
//Check country and redirect
string country = RegionInfo.CurrentRegion.DisplayName;
if (country == "France")
{
Response.Redirect("http://fr.mySite.org");
}
return base.Index(model);
}
public ActionResult Index()
{
return View();
}
}
我用路线劫持的方法得到了某种效果:
public class HomePageController : Umbraco.Web.Mvc.RenderMvcController
{
// GET: HomePage
public override ActionResult Index(RenderModel model)
{
//Check country and redirect
string country = RegionInfo.CurrentRegion.DisplayName;
if (country == "France")
{
Response.Redirect("http://fr.mySite.org");
}
return base.Index(model);
}
public ActionResult Index()
{
return View();
}
}