阅读Guru-Gu关于ASP.NET MVC3击中RC的博文,他说: -
无会话控制器支持
您现在可以指示是否希望Controller类使用会话状态 - 如果需要,是否要将其设置为读/写或readonly.read/write或readonly.
有人可以解释某些情况下有人可能希望拥有无会话控制器吗?或只读控制器?
我一直在创建一个单独的IIS网站,我用它处理所有静态图像/内容,然后让这个相同的网站关闭会话状态 ...所以没有通过网络发送cookie.这是一个类似的情况吗?
我有一个ASP.NET MVC3应用程序,其中我的动作生成一个id列表,我想让后续的AJAX请求可用.这样我就可以在后台运行一个漫长的过程并对其进行轮询.id列表是这个长时间运行过程的必要输入.我不想在URL中将它们作为参数传递,因为列表可能会很长并且会导致IE出现问题.
我的控制器
public ActionResult Run()
{
List<MyObjs> objs = _db.MyObjs.ToList<MyObjs>();
string uniqueId = Guid.NewGuid().ToString();
ViewData["UniqueID"] = uniqueId;
TempData["ObjIdList" + uniqueId] = String.Join(",", objs .Select(o => o.ObjID).ToArray<int>());
return View(objs);
}
public void StartProcess(string uid)
{
string ids = TempData["ObjIdList" + id].ToString().Split(',');
...
}
Run Code Online (Sandbox Code Playgroud)
我的看法
var uniqueId = '@ViewData["UniqueID"]';
$(document).ready(function (event) {
$('#startProcess').click(function () {
$.post("/Scheduler/StartProcess", { uid: uniqueId }, function () {
getStatus();
});
event.preventDefault;
});
});
function getStatus() {
var r = new Date().getTime(); // cache killer for IE …Run Code Online (Sandbox Code Playgroud) 我正在尝试从同时具有查询字符串和模型的控制器返回查看
return View("BillingReport.aspx/?report=" + fc["report_selector"], bilDet);
Run Code Online (Sandbox Code Playgroud)
但这给了我一个页面找不到的运行时错误,因为它在URL末尾附加了.aspx等。
RedirectToAction()没有选择这样做。
有没有办法做到这一点,还是mvc3将我们限制为使用查询字符串或模型?
您如何通过RedirectAction方法将模型从(GetDate)操作传递到另一个(ProcessP)操作?
这是源代码:
[HttpPost]
public ActionResult GetDate(FormCollection values, DateParameter newDateParameter)
{
if (ModelState.IsValid)
{
return RedirectToAction("ProcessP");
}
else
{
return View(newDateParameter);
}
}
public ActionResult ProcessP()
{
//Access the model from GetDate here??
var model = (from p in _db.blah
orderby p.CreateDate descending
select p).Take(10);
return View(model);
}
Run Code Online (Sandbox Code Playgroud) 我需要将对象列表从一个控制器传递到另一个控制器.我已经阅读了类似问题的答案,但没有什么可以帮助我.这是第一个控制器的代码:
[HttpPost]
public ActionResult Admin_Mgmt(List<thing> things, int Action_Code)
{
switch (Action_Code)
{
case 1:
{ //redirecting requesting to another controller
return RedirectToAction("Quran_Loading", "Request_Handler",things);
}
default:
...
}
}
Run Code Online (Sandbox Code Playgroud)
Request_Handler代码:
public class Request_HandlerController : Controller
{
public ActionResult Quran_Loading(List<thing> thin)
{...}
}
Run Code Online (Sandbox Code Playgroud)
但问题是Quran_Loading方法中的列表为null.任何的想法 ?