ASP.NET MVC的会话状态 [英] ASP.NET MVC Session State

查看:165
本文介绍了ASP.NET MVC的会话状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在试图创建与使用jQuery MVC中的进度条上传控件。我一直运行到一个问题,但是在MVC不并行线程工作?

I am currently trying to create an upload control with progress bar in MVC using jquery. I keep running into a problem however in that mvc doesn't work in parallel threads?

当我上传文件,并显示通过几个回调服务器执行从JS上传过程中的进展,我试图从服务器附带只有当该文件已被上传回,以获取有关当前上传状态,但答案的信息。

When I upload a file and show the progress during upload from JS performed through several callbacks to server, I am trying to get information about current upload state but answer from server comes back only when the file has been uploaded.

你知道的任何方式来获得在MVC的会话状态的查询不断或者执行的请求?

Do you know of any way to get session state queries in MVC constantly or when request is performed ?

真的AP preciate一些帮助,我相信其他人会如果有人知道答案!

Would really appreciate some help and I am sure others would if someone knows the answer!!

推荐答案

您将失去你的视图状态,如果你调用返回视图的操作。如果你喜欢,你可以通过使用TempData的行动之间的数据,但可能不会解决你的问题。听起来像你对我想在这里的是,它将返回你可以用一些异步JavaScript调用一个JSON元素的动作。

You will lose your view state if you call an action that returns a View. You can pass data between actions using the TempData if you like, but that probably won't solve your problem. Sounds to me like what you want here is an action that will return a JSON element that you can call with some asynchronous javascript.

有关你的行动,你将有:

For your action you would have:

public ActionResult GetSuggestions(string searchText)
{
    return Json(new { SearchText = searchText + "completestring"});
}

然后在窗体上有使用jQuery一些异步JavaScript:

And then on your form you have some asynchronous javascript using jQuery:

function startAutoComplete() {
    var searchText = $("#inputText").val();
    $.getJSON("/Search/GetSuggestions?searchText=" + searchText, null, autoCompleteResponse);
}

function autoCompleteResponse(data) {
    if (data.SearchText) {
        $("#inputText").val(data.SearchText);
        $("#inputText").select();
    }
}

这将让你从你的服务器的一些信息,而无需发布的形式和保持客户的视图状态在机智。

This will allow you to get some information from your server without posting the form and keeping the viewstate of the client in tact.

还有的全写起来例如这里这可能会有帮助。

这篇关于ASP.NET MVC的会话状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆