Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 4 带重定向路由的ASP MVC部分表单Post_Asp.net Mvc 4_Redirecttoroute - Fatal编程技术网

Asp.net mvc 4 带重定向路由的ASP MVC部分表单Post

Asp.net mvc 4 带重定向路由的ASP MVC部分表单Post,asp.net-mvc-4,redirecttoroute,Asp.net Mvc 4,Redirecttoroute,我的应用程序布局有一个分部,它是一个带有文本框和下拉列表的表单。根据输入/选择的条件,form post在基本控制器中执行重定向路由。但是,页面加载时间太长,似乎挂起了重定向。竞争对手网站的重定向(使用看似PHP的东西)速度极快。是什么导致RedirectToRoute中的速度缓慢?是否有其他方法可用于评估流程在表单post上的流向 <div class="search_widget"> <h2>&nbsp;</h2> <div class="p

我的应用程序布局有一个分部,它是一个带有文本框和下拉列表的表单。根据输入/选择的条件,form post在基本控制器中执行重定向路由。但是,页面加载时间太长,似乎挂起了重定向。竞争对手网站的重定向(使用看似PHP的东西)速度极快。是什么导致RedirectToRoute中的速度缓慢?是否有其他方法可用于评估流程在表单post上的流向

<div class="search_widget">
<h2>&nbsp;</h2>
<div class="property-filter-header">
    <div class="content">
        @*<h4>FIND SENIOR HOUSING<br />AND CARE</h4>*@
        <h4>FIND SENIOR HOUSING AND CARE</h4>
    </div>
</div>
<div class="property-filter">
    <div class="content">
        @using (Html.BeginForm("SearchCare", "Base", FormMethod.Post, new { id = "searchForm" }))
        {
            <div class="location control-group">
                <label class="control-label" for="Location">
                    Enter/select location
                </label>
                <div class="controls">
                    @Html.TextBoxFor(model => model.Location, new { @class = "location", placeholder = "City and State", required = "required" })
                </div><!-- /.controls -->

            </div><!-- /.control-group -->

            <div class="type control-group">
                <label class="control-label" for="Level">
                    Select an option
                </label>
                <div class="controls">
                    @Html.DropDownListFor(model => model.Level, AFS.HelperClasses.Lookups.LevelOfCare.LevelOfCareSelectList, " ", new { required = "required" })
                </div><!-- /.controls -->
            </div><!-- /.control-group -->

            <div class="form-actions">
                <input type="submit" value="Search!" class="btn btn-primary btn-large">
            </div><!-- /.form-actions -->
            <div style="text-align: center; margin-top: 10px;">
                <img src="@Url.Content("~/assets/img/sunburst-yellow.png")" alt="AFS sunburst" />
            </div>
            @Html.Hidden("city");
            @Html.Hidden("state");
            @Html.Hidden("lat");
            @Html.Hidden("lng");
        }
    </div><!-- /.content -->
</div><!-- /.property-filter -->

提前谢谢

请您展示一下代码好吗?我现在已经尝试过使用输出缓存、删除图像、javascript,甚至数据访问方法。这些都不能解决页面重定向/加载问题。我不明白为什么您要将一个
id=“searchForm”
传递给您的操作,但在您的操作中,您检索了
SearchCare(SearchModel model,FormCollection form)
,这就是为什么您的活页夹试图转换所有字段以构建您的SearchModel。我可以看看您的
搜索模型的定义吗?我还建议您将
dropDownList
链接到Ajax方法SearchModel基本上有三个值,其中一个值根据部分出现的页面填充,并设置下拉列表的值。它还将所选位置从用户传递到post操作。id可能是从早期版本的开发中设置的,不需要在那里。
[HttpPost]
    public ActionResult SearchCare(SearchModel model, FormCollection form)
    {
        if (ModelState.IsValid)
        {
            string state = form["state"].ToString();
            string city = form["city"].ToString();
            string lat = form["lat"].ToString();
            string lng = form["lng"].ToString();

            if (string.IsNullOrEmpty(state) || string.IsNullOrEmpty(city))
            {
                string[] location = model.Location.Split(',');
                city = location[0].Replace(" ", "-");
                if (location.Length > 1)
                {
                    state = location[1].Trim();
                }
                else
                {
                    return RedirectToAction("Location", "Errors", new { location = model.Location });
                }
            }
            string controller = "";
            switch (model.Level)
            {
                case 1:
                    controller = "AdultDayCare";
                    return RedirectToRoute("AdultDayCareByLocation", new { State = state, City = city });
                case 2:
                    controller = "AlzheimersSpecialty";
                    return RedirectToRoute("AlzheimersSpecialtyByLocation", new { State = state, City = city });
                case 3:
                    controller = "AssistedLiving";
                    return RedirectToRoute("AssistedLivingByLocation", new { State = state, City = city});
                    //return RedirectToRoute("AssistedLivingByLocation", new { State = state, City = city, latitude = lat, longitude = lng });
                case 4:
                    controller = "ContinuingCare";
                    return RedirectToRoute("ContinuingCareByLocation", new { State = state, City = city });
                case 5:
                    controller = "HomeCare";
                    return RedirectToRoute("HomeCareByLocation", new { State = state, City = city });
                case 6:
                    controller = "Hospice";
                    return RedirectToRoute("HospiceByLocation", new { State = state, City = city });
                case 7:
                    controller = "IndependentLiving";
                    return RedirectToRoute("IndependentLivingByLocation", new { State = state, City = city });
                case 8:
                    controller = "Nursing";
                    return RedirectToRoute("NursingByLocation", new { State = state, City = city });
                case 9:
                    controller = "ResidentialCare";
                    return RedirectToRoute("ResidentialCareByLocation", new { State = state, City = city });
                case 10:
                    controller = "SeniorApartments";
                    return RedirectToRoute("SeniorApartmentsByLocation", new { State = state, City = city });

            };
            return RedirectToAction("Results", controller, new { State = state, City = city });
        }
        else
        {
            return RedirectToAction("SearchError");
        }
    }