小编Uma*_*han的帖子

根据IP将用户重定向到子域

我试图根据他的IP地址位置将用户重定向到子域.我有一个页面加载观察器,它在每个请求上运行一个函数,它获取用户位置,当我尝试重定向到另一个域时,它给我"太多重定向"错误,我无法找到解决此问题的方法.

目前我的代码如下所示

string CountryName = "";
var Country = HttpContext.Current.Response.Cookies["Country"];
Country.Expires = DateTime.Now.AddDays(365);
var ip = HttpContext.Current.Request.UserHostAddress;

if (!string.IsNullOrEmpty(ip) && ip != null && ip != "127.0.0.1")
{
    using (var client = new WebServiceClient(xxxxx, "xxxxxxxx"))
    {
        var IpCountry = client.Country(ip);
        CountryName = IpCountry.Country.Name;
    }
    switch (CountryName)
    {
        case "Denmark":
            if (Country.Value != CountryName)
            {
                Country.Value = CountryName;
                HttpContext.Current.Response.Redirect("/");
            }
            break;
        case "United Kingdom":
            if (Country.Value != CountryName)
            {
                Country.Value = CountryName;
                HttpContext.Current.Response.Redirect("/en");
            }
            break;
        case "Germany":
            if (Country.Value != CountryName) …
Run Code Online (Sandbox Code Playgroud)

.net c# redirect response.redirect http-redirect

7
推荐指数
1
解决办法
1334
查看次数

单击父li时展开子ul

我有以下结构:

<div class="Downloadscontainer">
<ul>
    <li>level 1</li>
    <li><a href="#">level 1</a>
        <ul>
            <li>level 2</li>
             <li>level 2</li>
             <li><a href="#">some page</a>
            <ul>
                <li>level 2</li>
                <li>level 2</li>
                 </ul>
            </li>
        </ul>
    </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

我试图在点击其父li时显示ul,以下是我的jquery

 $(document).ready(function () {
    $(".Downloadscontainer ul li ul").css("display", "none");
    $(".Downloadscontainer li").each(function () {
        $(this).click(function () {
            if ($(this).children('ul').length > 0) {
                $('.Downloadscontainer li ul').toggle();
            }
        });
    });
});
Run Code Online (Sandbox Code Playgroud)

因此,如果我点击1级,LI它会显示UL,然后如果我点击2级LI,它UL也会关闭UL1级LI; 我希望继续打开这个孩子UL.我如何获得此功能?

链接到小提琴

html javascript jquery

3
推荐指数
1
解决办法
6507
查看次数