[Mono-list] MVC 3 error using Get/Post methods for an action with the same name
Eddy Zavaleta
eddy at mictlanix.org
Tue Aug 16 09:43:15 EDT 2011
Hi,
I'm facing troubles when I try to run a simple MVC 3 (Razor) CRUD
application. I got the following error when I visit an url which have
Get/Post methods for an action with the same name in the same controller.
System.FormatException: Index (zero based) must be greater than or
equal to zero and less than the size of the argument list.
at System.String.FormatHelper (System.Text.StringBuilder result,
IFormatProvider provider, System.String format, System.Object[] args)
[0x00000] in <filename unknown>:0
at System.String.Format (IFormatProvider provider, System.String
format, System.Object[] args) [0x00000] in <filename unknown>:0
at System.String.Format (System.String format, System.Object arg0,
System.Object arg1) [0x00000] in <filename unknown>:0
at System.ComponentModel.DataAnnotations.StringLengthAttribute.FormatErrorMessage
(System.String name) [0x00000] in <filename unknown>:0
at System.Web.Mvc.DataAnnotationsModelValidator.get_ErrorMessage ()
[0x00000] in <filename unknown>:0
at System.Web.Mvc.StringLengthAttributeAdapter.GetClientValidationRules
() [0x00000] in <filename unknown>:0
at System.Web.Mvc.HtmlHelper.<.ctor>b__1
(System.Web.Mvc.ModelValidator v) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable+<CreateSelectManyIterator>c__Iterator29`2[System.Web.Mvc.ModelValidator,System.Web.Mvc.ModelClientValidationRule].MoveNext
() [0x00000] in <filename unknown>:0
at System.Web.Mvc.HtmlHelper.GetUnobtrusiveValidationAttributes
(System.String name, System.Web.Mvc.ModelMetadata metadata) [0x00000]
in <filename unknown>:0
at System.Web.Mvc.Html.InputExtensions.InputHelper
(System.Web.Mvc.HtmlHelper htmlHelper, InputType inputType,
System.Web.Mvc.ModelMetadata metadata, System.String name,
System.Object value, Boolean useViewData, Boolean isChecked, Boolean
setId, Boolean isExplicitValue, IDictionary`2 htmlAttributes)
[0x00000] in <filename unknown>:0
at System.Web.Mvc.Html.InputExtensions.TextBox
(System.Web.Mvc.HtmlHelper htmlHelper, System.String name,
System.Object value, IDictionary`2 htmlAttributes) [0x00000] in
<filename unknown>:0
at System.Web.Mvc.Html.DefaultEditorTemplates.StringTemplate
(System.Web.Mvc.HtmlHelper html) [0x00000] in <filename unknown>:0
at System.Web.Mvc.Html.TemplateHelpers.ExecuteTemplate
(System.Web.Mvc.HtmlHelper html, System.Web.Mvc.ViewDataDictionary
viewData, System.String templateName, DataBoundControlMode mode,
System.Web.Mvc.Html.GetViewNamesDelegate getViewNames,
System.Web.Mvc.Html.GetDefaultActionsDelegate getDefaultActions)
[0x00000] in <filename unknown>:0
at (wrapper delegate-invoke)
<Module>:invoke_string__this___HtmlHelper_ViewDataDictionary_string_DataBoundControlMode_TemplateHelpers/GetViewNamesDelegate_TemplateHelpers/GetDefaultActionsDelegate
(System.Web.Mvc.HtmlHelper,System.Web.Mvc.ViewDataDictionary,string,System.Web.UI.WebControls.DataBoundControlMode,System.Web.Mvc.Html.TemplateHelpers/GetViewNamesDelegate,System.Web.Mvc.Html.TemplateHelpers/GetDefaultActionsDelegate)
at System.Web.Mvc.Html.TemplateHelpers.TemplateHelper
(System.Web.Mvc.HtmlHelper html, System.Web.Mvc.ModelMetadata
metadata, System.String htmlFieldName, System.String templateName,
DataBoundControlMode mode, System.Object additionalViewData,
System.Web.Mvc.Html.ExecuteTemplateDelegate executeTemplate) [0x00000]
in <filename unknown>:0
at System.Web.Mvc.Html.TemplateHelpers.TemplateHelper
(System.Web.Mvc.HtmlHelper html, System.Web.Mvc.ModelMetadata
metadata, System.String htmlFieldName, System.String templateName,
DataBoundControlMode mode, System.Object additionalViewData) [0x00000]
in <filename unknown>:0
at (wrapper delegate-invoke)
<Module>:invoke_string__this___HtmlHelper_ModelMetadata_string_string_DataBoundControlMode_object
(System.Web.Mvc.HtmlHelper,System.Web.Mvc.ModelMetadata,string,string,System.Web.UI.WebControls.DataBoundControlMode,object)
at System.Web.Mvc.Html.TemplateHelpers.TemplateFor[IEnumerable`1,String]
(System.Web.Mvc.HtmlHelper`1 html,
System.Linq.Expressions.Expression`1 expression, System.String
templateName, System.String htmlFieldName, DataBoundControlMode mode,
System.Object additionalViewData,
System.Web.Mvc.Html.TemplateHelperDelegate templateHelper) [0x00000]
in <filename unknown>:0
at System.Web.Mvc.Html.TemplateHelpers.TemplateFor[IEnumerable`1,String]
(System.Web.Mvc.HtmlHelper`1 html,
System.Linq.Expressions.Expression`1 expression, System.String
templateName, System.String htmlFieldName, DataBoundControlMode mode,
System.Object additionalViewData) [0x00000] in <filename unknown>:0
at System.Web.Mvc.Html.EditorExtensions.EditorFor[IEnumerable`1,String]
(System.Web.Mvc.HtmlHelper`1 html,
System.Linq.Expressions.Expression`1 expression) [0x00000] in
<filename unknown>:0
at ASP._Page_Views_Products_Index_cshtml.Execute () [0x00000] in
<filename unknown>:0
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy () [0x00000]
in <filename unknown>:0
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy () [0x00000] in
<filename unknown>:0
at System.Web.WebPages.StartPage.RunPage () [0x00000] in <filename unknown>:0
at System.Web.WebPages.StartPage.ExecutePageHierarchy () [0x00000]
in <filename unknown>:0
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy
(System.Web.WebPages.WebPageContext pageContext, System.IO.TextWriter
writer, System.Web.WebPages.WebPageRenderingBase startPage) [0x00000]
in <filename unknown>:0
at System.Web.Mvc.RazorView.RenderView (System.Web.Mvc.ViewContext
viewContext, System.IO.TextWriter writer, System.Object instance)
[0x00000] in <filename unknown>:0
at System.Web.Mvc.BuildManagerCompiledView.Render
(System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer)
[0x00000] in <filename unknown>:0
at System.Web.Mvc.ViewResultBase.ExecuteResult
(System.Web.Mvc.ControllerContext context) [0x00000] in <filename
unknown>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult
(System.Web.Mvc.ControllerContext controllerContext,
System.Web.Mvc.ActionResult actionResult) [0x00000] in <filename
unknown>:0
at System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19
() [0x00000] in <filename unknown>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter
(IResultFilter filter, System.Web.Mvc.ResultExecutingContext
preContext, System.Func`1 continuation) [0x00000] in <filename
unknown>:0
Here is a sample of what I've got in my app.
public class CategoriesController : Controller
{
//...
// GET: /Categories/Create
public ActionResult Create()
{
return View();
}
// POST: /Categories/Create
[HttpPost]
public ActionResult Create(Category category)
{
if (ModelState.IsValid)
{
//...
return RedirectToAction("Index");
}
return View(category);
}
//...
}
Version information:
Mono Runtime Version: 2.10.2
ASP.NET Version: 4.0.30319.1
--
Eddy Zavaleta
mictlanix.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20110816/e78f2dc1/attachment-0001.html
More information about the Mono-list
mailing list