不打扰的AJAX在IE中打开一个新标签

时间:2018-11-01 06:47:08

标签: asp.net-mvc unobtrusive-ajax

我在MVC中使用了简洁的Ajax来显示搜索结果,该结果在google chrome中效果很好,但是在IE中打开了一个新标签。这是我的html页面代码

@{
    AjaxOptions options = new AjaxOptions
    {
        HttpMethod="POST",
        UpdateTargetId = "searchResult",
        InsertionMode = InsertionMode.Replace,
        AllowCache = false


    };
}

 @using (Ajax.BeginForm("SearchContent", options))
                                {
                                    <div class="row no-gutters ">
                                        <div class="col">
                                            <!--<input class="form-control text-sm border-secondary border-right-0 rounded-0" type="search" placeholder="Search" id="Search">-->
                                            @Html.TextBox("SearchText", null, new { @class = "form-control-sm small-box mt-2 border-secondary border-right-0 rounded-0" })

                                        </div>
                                        <div class="col-auto">

                                            <button class="btn-search mt-2" type="submit">
                                                <i class="fa fa-search vertical-middle"></i>
                                            </button>
                                        </div>
                                    </div>
                                }
                                    <div id="searchResult">


                                    </div>

在控制器中,我正在使用此代码返回搜索到的元素

public PartialViewResult SearchContent(String SearchText)
    {
        List<SearchResult> Filenames = new List<SearchResult>();
        List<SearchResult> result = new List<SearchResult>();
        string path = Server.MapPath("~/Views");
        if (SearchText == null)
            SearchText = "";
        //path to start searching.
        if (Directory.Exists(path))
        {
            result = ProcessDirectory(path, SearchText, Filenames);
        }
        ViewData["result"] = result;
        return PartialView("~/Views/Home/SearchContent.cshtml");
    }

关于为何仅在IE中打开一个新标签并在其他浏览器中正常工作的帮助吗?

0 个答案:

没有答案