简体   繁体   English

页面在IIS7.5中返回异常,在VS2010调试中运行良好

[英]Page returns exception in IIS7.5, runs fine in VS2010 debug

Adding some code to an existing MVC webpage. 向现有的MVC网页添加一些代码。 All other parts of the site continue to work fine. 该网站的所有其他部分仍然可以正常工作。 Running Debug in VS2010, the code functions correctly. 在VS2010中运行Debug,代码可以正常运行。 After uploading to IIS 7.5 it returns the exception below. 上传到IIS 7.5后,它返回以下异常。 Any ideas? 有任何想法吗? Can provide additional code if needed. 如果需要,可以提供其他代码。

Thanks 谢谢


Value cannot be null.
Parameter name: String

   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.Int32.Parse(String s)
   at McCarterMobile.Controllers.CartController.RemoveContribution(FormCollection form) in V:\Google Drive\Websites\Mobile Site\McCarterMobile\Controllers\CartController.cs:line 391
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)

Here is the controller code. 这是控制器代码。

383            public ActionResult RemoveContribution(FormCollection form)
384        {
385            string sessionKey = "";
386
387            if (HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName] != null)
388            {
389                {
390                    sessionKey = FormsAuthentication.Decrypt(HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName].Value).UserData;
391                    repository.RemoveContribution(sessionKey, int.Parse(form["Ref_Num"]));
392                }
393                return RedirectToAction("Index");
394            }
395            else
396            {
397                return RedirectToAction("File Not Found", "Errors");
398            }
399        }

Here is the cshtml code 这是cshtml代码

@using (Html.BeginForm("RemoveContribution", "Cart"))
{
<input type="submit" data-role="button" data-inline="true" data-iconpos="notext" data-icon="delete" data-iconpos="right" />
<input type=hidden name=Ref_Num value='@c.RefNum' />
}

The MVC framework will handle the type conversions and such for you if you let it: MVC框架将处理类型转换,如果您愿意,它将为您处理:

public ActionResult RemoveContribution(int? Ref_Num = null)
{
    if (Ref_Num == null)
    {
        // report an error or whatever
    }
    else
    {
        // do something with Ref_Num
    }
}

There's a lot of code in the MVC framework to support this stuff so that you don't have to keep dealing with type conversions and such. MVC框架中有很多代码来支持这些内容,因此您不必继续处理类型转换等问题。

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

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