我的应用程序布局有一个部分,它是一个带有文本框和下拉列表的表单。根据输入/选择的标准,表单发布在基本控制器中执行RedirectToRoute。但是,页面加载时间过长,似乎挂起了重定向。竞争对手网站的重定向(使用看似PHP的东西)是闪电般快速的。什么可能导致RedirectToRoute的缓慢,是否有一个替代方法,这里应该用来评估进程应该在表单上流动的位置?
<div class="search_widget">
<h2> </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 -->
这是后期行动:
[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");
}
}
提前致谢!!