简体   繁体   English

将带有表单的请求发布到asp.net mvc路由

[英]Post a request with a form to an asp.net mvc route

A third party site will do a request containing a form to this route (I will load its content like xd.LoadXml(Request.Form["basket"]); ): 第三方站点将向该路由发出包含表单的请求(我将加载其内容,例如xd.LoadXml(Request.Form["basket"]); ):

www.mysite.com/iPaperCheckout

Can you please tell me where I am wrong because it's telling me: 您能告诉我哪里错了吗,因为它告诉我:

    The resource cannot be found.
Requested URL: /iPaperCheckout

I've registered my route for POST: 我已经为POST注册了路线:

routes.MapLocalizedRoute("ShoppingCartIPaper",
                        "iPaperCheckout",
                        new { controller = "ShoppingCart", action = "IPaperCheckout" },
                        new { httpMethod = new HttpMethodConstraint("POST") },
                        new[] { "Nop.Web.Controllers" });

I also added it in ShoppingCartController: 我还在ShoppingCartController中添加了它:

    [ValidateInput(false)]
    [HttpPost, ActionName("IPaperCheckout")]
    [FormValueRequired("basket")]
    public ActionResult IPaperCheckout(FormCollection form)
    {
         //code
     }

Do you see anything wrong from my side? 从我这边看到什么错了吗?

Shouldn't the url be something like www.mysite.com/PaperCheckoutApp/iPaperCheckout ? 网址不应该是www.mysite.com/PaperCheckoutApp/iPaperCheckout吗?

Using normal IIS + MVC conventions, www.mysite.com/iPaperCheckout would mean that the request is handled by an application called iPaperCheckout , and the application relative URL is an empty string. 使用常规的IIS + MVC约定, www.mysite.com/iPaperCheckout iPaperCheckout表示请求由名为iPaperCheckout的应用程序处理,并且应用程序相对URL为空字符串。 So by default the request would be handled by Home controller / Index action, if you have the defaults in you route map. 因此,默认情况下,如果路由映射中包含默认值,则请求将由本地控制器/索引操作处理。

So I would guess, that your application isn't running where you expect it to run. 因此,我想您的应用程序未在您期望的位置运行。 Do you run it under full IIS? 您是否在完整的IIS下运行它? Have you created the application properly? 您是否正确创建了应用程序? Is the application pool (.NET4 required if you running MVC3) running? 应用程序池(如果运行MVC3,则需要.NET4)在运行吗?

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

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