简体   繁体   English

使用 jQuery asp.net 重定向到新控制器并传递模型

[英]Redirect to new controller with jQuery asp.net and passing model

I have the following jQuery-code that make a POST:我有以下 jQuery 代码可以进行 POST:

$.ajax({
                url: 'http://localhost:65148/Home/BandRegister',
                data: formData,
                type: "POST",
                processData: false,
                contentType: false,
                success: function (data, textStatus, XMLHttpRequest) {
                    //location = data.url;
                    console.log(data);
                },
                error: function (data, textStatus, XMLHttpRequest) {
                    console.log(data);
                }
            });

I handle the post In the following controller:我在以下控制器中处理帖子:

    if (BandProfile != null)
    {
        userManager.AddToRole(UserId, "Band");
        return Json(new { url = Url.Action("Index", "Home", new { model = BandProfile }) }, JsonRequestBehavior.AllowGet);
    }

In the controller, I want to redirect to a new controller and view, and pass the model with me.在控制器中,我想重定向到一个新的控制器和视图,并将模型传递给我。 How can I do this with jQuery?我怎样才能用 jQuery 做到这一点?

Or should I just get the information from the database and make a new model object when I have redirected to the new controller?或者我应该从数据库中获取信息并在重定向到新控制器时创建一个新的模型对象? Thus skip to pass the model with me?因此跳过与我一起传递模型?

Here Is my HTML:这是我的 HTML:

Firstname: Lastname: Birth: Profile picture: Genre(loop out from table in database): Lägg till flera alternativ här. 名字: 姓氏: 出生: 个人资料图片: 流派(从数据库中的表中循环出): Lägg 直到 flera alternativ här。 Precis som när man ska tagga något Precis som när man ska tagga något

Create创建

I am capturing the input values with jquery.我正在使用 jquery 捕获输入值。

You can forward the request on the server.您可以在服务器上转发请求。 The client will not notice that,so jquery does not mattet for this.客户端不会注意到这一点,因此 jquery 不会对此进行掩饰。

I dont know how to do a forward on .net.我不知道如何在 .net 上进行转发。 but its part of the servlet spec so should be possible.但它是 servlet 规范的一部分,所以应该是可能的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM