The model item passed into the dictionary is of type, but this dictionary requires a model item of type...
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Here is what I am trying to do. I don't understand Why it is expecting an enumerable list.
AddressController.cs
public ActionResult ShowAddresses(List<Address> ReturnAddresses)
{
ShowAddressViewModel viewModel = new ShowAddressViewModel() { Addresses = ReturnAddresses, Message = "New" };
return PartialView("_ShowAddr", viewModel);
}
ShowAddressViewModel.cs
public class ShowAddressViewModel
{
public List<Address> Addresses { get; set; }
public string Message { get; set; }
}
_ShowAddr.cshtml
@model PeopleSoftControlsPOC.Models.ShowAddressViewModel
<script type="text/javascript">
</script>
<form>
<div class="addressBlock">
<table id="AddressTable">
@{int i = 0;}
@{PeopleSoftControlsPOC.Models.ShowAddressViewModel AddrModel = Model;}
@foreach (var item in AddrModel.Addresses)
{
<tr id = "@(i)">
<td>@(AddrModel.Addresses[i].Address1)
</td>
<td>@(AddrModel.Addresses[i].Address2)
</td>
<td>@(AddrModel.Addresses[i].City)
</td>
<td>@(AddrModel.Addresses[i].State)
</td>
<td>@(AddrModel.Addresses[i].Zip)
</td>
</tr>
@(i++)
}
</table>
</div>
</form>
edit
Call from Another partial view's java script
$.ajax(url, {
data: { ReturnAddresses : InboundAddresses },
type: 'POST',
cache: false,
crossDomain: true,
success: function (data) {
//Populate the form values
// Start Dialog Code
$myWindow = jQuery('#myDiv');
//instantiate the dialog
$myWindow.html(data);
$myWindow.dialog({
title: 'Select an address',
modal: true,
width: 'auto'
});
$myWindow.show();
$myWindow.dialog("open");
// End Dialog Code
$('#AddressTable').on('click', 'tr', function () {
alert('You clicked row ' + ($(this).index()));
});
addAddress(Addresses, Message)
},
error: function (jqXHR, textStatus, errorThrown) {
$('#Message').val('Kaboom!!! (The call blew up...#thatsucks)');
alert('The Dialog Box call failed...Sorry :(');
}
});
}
Server Error in '/PSPOC' Application.
--------------------------------------------------------------------------------
The model item passed into the dictionary is of type 'PeopleSoftControlsPOC.Models.ShowAddressViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[PeopleSoftControlsPOC.Models.ShowAddressViewModel]'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'PeopleSoftControlsPOC.Models.ShowAddressViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[PeopleSoftControlsPOC.Models.ShowAddressViewModel]'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The model item passed into the dictionary is of type 'PeopleSoftControlsPOC.Models.ShowAddressViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[PeopleSoftControlsPOC.Models.ShowAddressViewModel]'.]
System.Web.Mvc.ViewDataDictionary`1.SetModel(Object value) +383
System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary) +625
System.Web.Mvc.WebViewPage`1.SetViewData(ViewDataDictionary viewData) +74
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +138
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +378
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +727120
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +727076
System.Web.Mvc.Controller.ExecuteCore() +159
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +334
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +15
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +52
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18044
c# asp.net-mvc razor
|
show 4 more comments
Here is what I am trying to do. I don't understand Why it is expecting an enumerable list.
AddressController.cs
public ActionResult ShowAddresses(List<Address> ReturnAddresses)
{
ShowAddressViewModel viewModel = new ShowAddressViewModel() { Addresses = ReturnAddresses, Message = "New" };
return PartialView("_ShowAddr", viewModel);
}
ShowAddressViewModel.cs
public class ShowAddressViewModel
{
public List<Address> Addresses { get; set; }
public string Message { get; set; }
}
_ShowAddr.cshtml
@model PeopleSoftControlsPOC.Models.ShowAddressViewModel
<script type="text/javascript">
</script>
<form>
<div class="addressBlock">
<table id="AddressTable">
@{int i = 0;}
@{PeopleSoftControlsPOC.Models.ShowAddressViewModel AddrModel = Model;}
@foreach (var item in AddrModel.Addresses)
{
<tr id = "@(i)">
<td>@(AddrModel.Addresses[i].Address1)
</td>
<td>@(AddrModel.Addresses[i].Address2)
</td>
<td>@(AddrModel.Addresses[i].City)
</td>
<td>@(AddrModel.Addresses[i].State)
</td>
<td>@(AddrModel.Addresses[i].Zip)
</td>
</tr>
@(i++)
}
</table>
</div>
</form>
edit
Call from Another partial view's java script
$.ajax(url, {
data: { ReturnAddresses : InboundAddresses },
type: 'POST',
cache: false,
crossDomain: true,
success: function (data) {
//Populate the form values
// Start Dialog Code
$myWindow = jQuery('#myDiv');
//instantiate the dialog
$myWindow.html(data);
$myWindow.dialog({
title: 'Select an address',
modal: true,
width: 'auto'
});
$myWindow.show();
$myWindow.dialog("open");
// End Dialog Code
$('#AddressTable').on('click', 'tr', function () {
alert('You clicked row ' + ($(this).index()));
});
addAddress(Addresses, Message)
},
error: function (jqXHR, textStatus, errorThrown) {
$('#Message').val('Kaboom!!! (The call blew up...#thatsucks)');
alert('The Dialog Box call failed...Sorry :(');
}
});
}
Server Error in '/PSPOC' Application.
--------------------------------------------------------------------------------
The model item passed into the dictionary is of type 'PeopleSoftControlsPOC.Models.ShowAddressViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[PeopleSoftControlsPOC.Models.ShowAddressViewModel]'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'PeopleSoftControlsPOC.Models.ShowAddressViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[PeopleSoftControlsPOC.Models.ShowAddressViewModel]'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The model item passed into the dictionary is of type 'PeopleSoftControlsPOC.Models.ShowAddressViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[PeopleSoftControlsPOC.Models.ShowAddressViewModel]'.]
System.Web.Mvc.ViewDataDictionary`1.SetModel(Object value) +383
System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary) +625
System.Web.Mvc.WebViewPage`1.SetViewData(ViewDataDictionary viewData) +74
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +138
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +378
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +727120
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +727076
System.Web.Mvc.Controller.ExecuteCore() +159
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +334
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +15
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +52
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18044
c# asp.net-mvc razor
3
Whereabouts are you getting this error - in the foreach in the Razor file? And why are you usingAddrModel.Addresses[i].Cityrather than justitem.Cityetc.
– Rup
Oct 9 '13 at 15:52
And should your@(i++)have curly braces not round brackets? (guessing from the other code, I've never used Razor)
– Rup
Oct 9 '13 at 15:55
@Rup Look at<tr id="@(i)">
– millimoose
Oct 9 '13 at 15:55
I am calling this method from another partial view's javascript which is returning a Internal server error 500. I am new to MVC or anything related to C# for that matter. I got the error message from fiddler. All the razor script I have to make changes. But, even if I take out all the razor script, I still got that error
– Sat
Oct 9 '13 at 15:55
Set your action to be of type PartialViewResult instead of ActionResult. Also, please show the call to the action, are you using RenderAction?...
– Lars Anundskås
Oct 9 '13 at 15:57
|
show 4 more comments
Here is what I am trying to do. I don't understand Why it is expecting an enumerable list.
AddressController.cs
public ActionResult ShowAddresses(List<Address> ReturnAddresses)
{
ShowAddressViewModel viewModel = new ShowAddressViewModel() { Addresses = ReturnAddresses, Message = "New" };
return PartialView("_ShowAddr", viewModel);
}
ShowAddressViewModel.cs
public class ShowAddressViewModel
{
public List<Address> Addresses { get; set; }
public string Message { get; set; }
}
_ShowAddr.cshtml
@model PeopleSoftControlsPOC.Models.ShowAddressViewModel
<script type="text/javascript">
</script>
<form>
<div class="addressBlock">
<table id="AddressTable">
@{int i = 0;}
@{PeopleSoftControlsPOC.Models.ShowAddressViewModel AddrModel = Model;}
@foreach (var item in AddrModel.Addresses)
{
<tr id = "@(i)">
<td>@(AddrModel.Addresses[i].Address1)
</td>
<td>@(AddrModel.Addresses[i].Address2)
</td>
<td>@(AddrModel.Addresses[i].City)
</td>
<td>@(AddrModel.Addresses[i].State)
</td>
<td>@(AddrModel.Addresses[i].Zip)
</td>
</tr>
@(i++)
}
</table>
</div>
</form>
edit
Call from Another partial view's java script
$.ajax(url, {
data: { ReturnAddresses : InboundAddresses },
type: 'POST',
cache: false,
crossDomain: true,
success: function (data) {
//Populate the form values
// Start Dialog Code
$myWindow = jQuery('#myDiv');
//instantiate the dialog
$myWindow.html(data);
$myWindow.dialog({
title: 'Select an address',
modal: true,
width: 'auto'
});
$myWindow.show();
$myWindow.dialog("open");
// End Dialog Code
$('#AddressTable').on('click', 'tr', function () {
alert('You clicked row ' + ($(this).index()));
});
addAddress(Addresses, Message)
},
error: function (jqXHR, textStatus, errorThrown) {
$('#Message').val('Kaboom!!! (The call blew up...#thatsucks)');
alert('The Dialog Box call failed...Sorry :(');
}
});
}
Server Error in '/PSPOC' Application.
--------------------------------------------------------------------------------
The model item passed into the dictionary is of type 'PeopleSoftControlsPOC.Models.ShowAddressViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[PeopleSoftControlsPOC.Models.ShowAddressViewModel]'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'PeopleSoftControlsPOC.Models.ShowAddressViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[PeopleSoftControlsPOC.Models.ShowAddressViewModel]'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The model item passed into the dictionary is of type 'PeopleSoftControlsPOC.Models.ShowAddressViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[PeopleSoftControlsPOC.Models.ShowAddressViewModel]'.]
System.Web.Mvc.ViewDataDictionary`1.SetModel(Object value) +383
System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary) +625
System.Web.Mvc.WebViewPage`1.SetViewData(ViewDataDictionary viewData) +74
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +138
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +378
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +727120
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +727076
System.Web.Mvc.Controller.ExecuteCore() +159
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +334
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +15
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +52
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18044
c# asp.net-mvc razor
Here is what I am trying to do. I don't understand Why it is expecting an enumerable list.
AddressController.cs
public ActionResult ShowAddresses(List<Address> ReturnAddresses)
{
ShowAddressViewModel viewModel = new ShowAddressViewModel() { Addresses = ReturnAddresses, Message = "New" };
return PartialView("_ShowAddr", viewModel);
}
ShowAddressViewModel.cs
public class ShowAddressViewModel
{
public List<Address> Addresses { get; set; }
public string Message { get; set; }
}
_ShowAddr.cshtml
@model PeopleSoftControlsPOC.Models.ShowAddressViewModel
<script type="text/javascript">
</script>
<form>
<div class="addressBlock">
<table id="AddressTable">
@{int i = 0;}
@{PeopleSoftControlsPOC.Models.ShowAddressViewModel AddrModel = Model;}
@foreach (var item in AddrModel.Addresses)
{
<tr id = "@(i)">
<td>@(AddrModel.Addresses[i].Address1)
</td>
<td>@(AddrModel.Addresses[i].Address2)
</td>
<td>@(AddrModel.Addresses[i].City)
</td>
<td>@(AddrModel.Addresses[i].State)
</td>
<td>@(AddrModel.Addresses[i].Zip)
</td>
</tr>
@(i++)
}
</table>
</div>
</form>
edit
Call from Another partial view's java script
$.ajax(url, {
data: { ReturnAddresses : InboundAddresses },
type: 'POST',
cache: false,
crossDomain: true,
success: function (data) {
//Populate the form values
// Start Dialog Code
$myWindow = jQuery('#myDiv');
//instantiate the dialog
$myWindow.html(data);
$myWindow.dialog({
title: 'Select an address',
modal: true,
width: 'auto'
});
$myWindow.show();
$myWindow.dialog("open");
// End Dialog Code
$('#AddressTable').on('click', 'tr', function () {
alert('You clicked row ' + ($(this).index()));
});
addAddress(Addresses, Message)
},
error: function (jqXHR, textStatus, errorThrown) {
$('#Message').val('Kaboom!!! (The call blew up...#thatsucks)');
alert('The Dialog Box call failed...Sorry :(');
}
});
}
Server Error in '/PSPOC' Application.
--------------------------------------------------------------------------------
The model item passed into the dictionary is of type 'PeopleSoftControlsPOC.Models.ShowAddressViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[PeopleSoftControlsPOC.Models.ShowAddressViewModel]'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'PeopleSoftControlsPOC.Models.ShowAddressViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[PeopleSoftControlsPOC.Models.ShowAddressViewModel]'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The model item passed into the dictionary is of type 'PeopleSoftControlsPOC.Models.ShowAddressViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[PeopleSoftControlsPOC.Models.ShowAddressViewModel]'.]
System.Web.Mvc.ViewDataDictionary`1.SetModel(Object value) +383
System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary) +625
System.Web.Mvc.WebViewPage`1.SetViewData(ViewDataDictionary viewData) +74
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +138
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +378
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +727120
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +727076
System.Web.Mvc.Controller.ExecuteCore() +159
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +334
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +15
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +52
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18044
c# asp.net-mvc razor
c# asp.net-mvc razor
edited Oct 9 '13 at 16:46
Sat
asked Oct 9 '13 at 15:50
SatSat
95113
95113
3
Whereabouts are you getting this error - in the foreach in the Razor file? And why are you usingAddrModel.Addresses[i].Cityrather than justitem.Cityetc.
– Rup
Oct 9 '13 at 15:52
And should your@(i++)have curly braces not round brackets? (guessing from the other code, I've never used Razor)
– Rup
Oct 9 '13 at 15:55
@Rup Look at<tr id="@(i)">
– millimoose
Oct 9 '13 at 15:55
I am calling this method from another partial view's javascript which is returning a Internal server error 500. I am new to MVC or anything related to C# for that matter. I got the error message from fiddler. All the razor script I have to make changes. But, even if I take out all the razor script, I still got that error
– Sat
Oct 9 '13 at 15:55
Set your action to be of type PartialViewResult instead of ActionResult. Also, please show the call to the action, are you using RenderAction?...
– Lars Anundskås
Oct 9 '13 at 15:57
|
show 4 more comments
3
Whereabouts are you getting this error - in the foreach in the Razor file? And why are you usingAddrModel.Addresses[i].Cityrather than justitem.Cityetc.
– Rup
Oct 9 '13 at 15:52
And should your@(i++)have curly braces not round brackets? (guessing from the other code, I've never used Razor)
– Rup
Oct 9 '13 at 15:55
@Rup Look at<tr id="@(i)">
– millimoose
Oct 9 '13 at 15:55
I am calling this method from another partial view's javascript which is returning a Internal server error 500. I am new to MVC or anything related to C# for that matter. I got the error message from fiddler. All the razor script I have to make changes. But, even if I take out all the razor script, I still got that error
– Sat
Oct 9 '13 at 15:55
Set your action to be of type PartialViewResult instead of ActionResult. Also, please show the call to the action, are you using RenderAction?...
– Lars Anundskås
Oct 9 '13 at 15:57
3
3
Whereabouts are you getting this error - in the foreach in the Razor file? And why are you using
AddrModel.Addresses[i].City rather than just item.City etc.– Rup
Oct 9 '13 at 15:52
Whereabouts are you getting this error - in the foreach in the Razor file? And why are you using
AddrModel.Addresses[i].City rather than just item.City etc.– Rup
Oct 9 '13 at 15:52
And should your
@(i++) have curly braces not round brackets? (guessing from the other code, I've never used Razor)– Rup
Oct 9 '13 at 15:55
And should your
@(i++) have curly braces not round brackets? (guessing from the other code, I've never used Razor)– Rup
Oct 9 '13 at 15:55
@Rup Look at
<tr id="@(i)">– millimoose
Oct 9 '13 at 15:55
@Rup Look at
<tr id="@(i)">– millimoose
Oct 9 '13 at 15:55
I am calling this method from another partial view's javascript which is returning a Internal server error 500. I am new to MVC or anything related to C# for that matter. I got the error message from fiddler. All the razor script I have to make changes. But, even if I take out all the razor script, I still got that error
– Sat
Oct 9 '13 at 15:55
I am calling this method from another partial view's javascript which is returning a Internal server error 500. I am new to MVC or anything related to C# for that matter. I got the error message from fiddler. All the razor script I have to make changes. But, even if I take out all the razor script, I still got that error
– Sat
Oct 9 '13 at 15:55
Set your action to be of type PartialViewResult instead of ActionResult. Also, please show the call to the action, are you using RenderAction?...
– Lars Anundskås
Oct 9 '13 at 15:57
Set your action to be of type PartialViewResult instead of ActionResult. Also, please show the call to the action, are you using RenderAction?...
– Lars Anundskås
Oct 9 '13 at 15:57
|
show 4 more comments
2 Answers
2
active
oldest
votes
Assuming that you are trying to render your view with
@Html.Partial("_ShowAddr", Model.Adr)
And your model are sent to the view without going through the controller, so you are actually sending the view a collection of addresses instead of the wrapped viewmodel.
Try this approach instead:
@{ Html.RenderAction("ShowAddresses", Model.Adr); }
EDIT
Actually:
@{ Html.RenderAction("TestPart", new { ReturnAddresses = Model.Adr }); }
I am not using razor to render the page. Please see my javascript on how I am using the returned partial view.
– Sat
Oct 9 '13 at 17:18
how does the post look like if you inspect in fiddler/firebug, what is the contents of data: { ReturnAddresses : InboundAddresses },
– Lars Anundskås
Oct 9 '13 at 19:23
Lars, Rebuilding the project made it start working. I don't know what happened. Thanks for the help. I really appreciate it. To answer your question, InboundAddresses is an array of address objects. an address object is defined locally and consists of address information.
– Sat
Oct 9 '13 at 20:23
add a comment |
i think is
return PartialView("_ShowAddr", viewModel.ToList());And in the top of your _ShowAddr.cshtml
@model IEnumerable<PeopleSoftControlsPOC.Models.ShowAddressViewModel>im doing something like you
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19276772%2fthe-model-item-passed-into-the-dictionary-is-of-type-but-this-dictionary-requir%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Assuming that you are trying to render your view with
@Html.Partial("_ShowAddr", Model.Adr)
And your model are sent to the view without going through the controller, so you are actually sending the view a collection of addresses instead of the wrapped viewmodel.
Try this approach instead:
@{ Html.RenderAction("ShowAddresses", Model.Adr); }
EDIT
Actually:
@{ Html.RenderAction("TestPart", new { ReturnAddresses = Model.Adr }); }
I am not using razor to render the page. Please see my javascript on how I am using the returned partial view.
– Sat
Oct 9 '13 at 17:18
how does the post look like if you inspect in fiddler/firebug, what is the contents of data: { ReturnAddresses : InboundAddresses },
– Lars Anundskås
Oct 9 '13 at 19:23
Lars, Rebuilding the project made it start working. I don't know what happened. Thanks for the help. I really appreciate it. To answer your question, InboundAddresses is an array of address objects. an address object is defined locally and consists of address information.
– Sat
Oct 9 '13 at 20:23
add a comment |
Assuming that you are trying to render your view with
@Html.Partial("_ShowAddr", Model.Adr)
And your model are sent to the view without going through the controller, so you are actually sending the view a collection of addresses instead of the wrapped viewmodel.
Try this approach instead:
@{ Html.RenderAction("ShowAddresses", Model.Adr); }
EDIT
Actually:
@{ Html.RenderAction("TestPart", new { ReturnAddresses = Model.Adr }); }
I am not using razor to render the page. Please see my javascript on how I am using the returned partial view.
– Sat
Oct 9 '13 at 17:18
how does the post look like if you inspect in fiddler/firebug, what is the contents of data: { ReturnAddresses : InboundAddresses },
– Lars Anundskås
Oct 9 '13 at 19:23
Lars, Rebuilding the project made it start working. I don't know what happened. Thanks for the help. I really appreciate it. To answer your question, InboundAddresses is an array of address objects. an address object is defined locally and consists of address information.
– Sat
Oct 9 '13 at 20:23
add a comment |
Assuming that you are trying to render your view with
@Html.Partial("_ShowAddr", Model.Adr)
And your model are sent to the view without going through the controller, so you are actually sending the view a collection of addresses instead of the wrapped viewmodel.
Try this approach instead:
@{ Html.RenderAction("ShowAddresses", Model.Adr); }
EDIT
Actually:
@{ Html.RenderAction("TestPart", new { ReturnAddresses = Model.Adr }); }
Assuming that you are trying to render your view with
@Html.Partial("_ShowAddr", Model.Adr)
And your model are sent to the view without going through the controller, so you are actually sending the view a collection of addresses instead of the wrapped viewmodel.
Try this approach instead:
@{ Html.RenderAction("ShowAddresses", Model.Adr); }
EDIT
Actually:
@{ Html.RenderAction("TestPart", new { ReturnAddresses = Model.Adr }); }
edited Oct 9 '13 at 16:20
answered Oct 9 '13 at 16:12
Lars AnundskåsLars Anundskås
1,090722
1,090722
I am not using razor to render the page. Please see my javascript on how I am using the returned partial view.
– Sat
Oct 9 '13 at 17:18
how does the post look like if you inspect in fiddler/firebug, what is the contents of data: { ReturnAddresses : InboundAddresses },
– Lars Anundskås
Oct 9 '13 at 19:23
Lars, Rebuilding the project made it start working. I don't know what happened. Thanks for the help. I really appreciate it. To answer your question, InboundAddresses is an array of address objects. an address object is defined locally and consists of address information.
– Sat
Oct 9 '13 at 20:23
add a comment |
I am not using razor to render the page. Please see my javascript on how I am using the returned partial view.
– Sat
Oct 9 '13 at 17:18
how does the post look like if you inspect in fiddler/firebug, what is the contents of data: { ReturnAddresses : InboundAddresses },
– Lars Anundskås
Oct 9 '13 at 19:23
Lars, Rebuilding the project made it start working. I don't know what happened. Thanks for the help. I really appreciate it. To answer your question, InboundAddresses is an array of address objects. an address object is defined locally and consists of address information.
– Sat
Oct 9 '13 at 20:23
I am not using razor to render the page. Please see my javascript on how I am using the returned partial view.
– Sat
Oct 9 '13 at 17:18
I am not using razor to render the page. Please see my javascript on how I am using the returned partial view.
– Sat
Oct 9 '13 at 17:18
how does the post look like if you inspect in fiddler/firebug, what is the contents of data: { ReturnAddresses : InboundAddresses },
– Lars Anundskås
Oct 9 '13 at 19:23
how does the post look like if you inspect in fiddler/firebug, what is the contents of data: { ReturnAddresses : InboundAddresses },
– Lars Anundskås
Oct 9 '13 at 19:23
Lars, Rebuilding the project made it start working. I don't know what happened. Thanks for the help. I really appreciate it. To answer your question, InboundAddresses is an array of address objects. an address object is defined locally and consists of address information.
– Sat
Oct 9 '13 at 20:23
Lars, Rebuilding the project made it start working. I don't know what happened. Thanks for the help. I really appreciate it. To answer your question, InboundAddresses is an array of address objects. an address object is defined locally and consists of address information.
– Sat
Oct 9 '13 at 20:23
add a comment |
i think is
return PartialView("_ShowAddr", viewModel.ToList());And in the top of your _ShowAddr.cshtml
@model IEnumerable<PeopleSoftControlsPOC.Models.ShowAddressViewModel>im doing something like you
add a comment |
i think is
return PartialView("_ShowAddr", viewModel.ToList());And in the top of your _ShowAddr.cshtml
@model IEnumerable<PeopleSoftControlsPOC.Models.ShowAddressViewModel>im doing something like you
add a comment |
i think is
return PartialView("_ShowAddr", viewModel.ToList());And in the top of your _ShowAddr.cshtml
@model IEnumerable<PeopleSoftControlsPOC.Models.ShowAddressViewModel>im doing something like you
i think is
return PartialView("_ShowAddr", viewModel.ToList());And in the top of your _ShowAddr.cshtml
@model IEnumerable<PeopleSoftControlsPOC.Models.ShowAddressViewModel>im doing something like you
return PartialView("_ShowAddr", viewModel.ToList());return PartialView("_ShowAddr", viewModel.ToList());@model IEnumerable<PeopleSoftControlsPOC.Models.ShowAddressViewModel>@model IEnumerable<PeopleSoftControlsPOC.Models.ShowAddressViewModel>answered Sep 13 '16 at 19:26
XiqueXique
251410
251410
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19276772%2fthe-model-item-passed-into-the-dictionary-is-of-type-but-this-dictionary-requir%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Whereabouts are you getting this error - in the foreach in the Razor file? And why are you using
AddrModel.Addresses[i].Cityrather than justitem.Cityetc.– Rup
Oct 9 '13 at 15:52
And should your
@(i++)have curly braces not round brackets? (guessing from the other code, I've never used Razor)– Rup
Oct 9 '13 at 15:55
@Rup Look at
<tr id="@(i)">– millimoose
Oct 9 '13 at 15:55
I am calling this method from another partial view's javascript which is returning a Internal server error 500. I am new to MVC or anything related to C# for that matter. I got the error message from fiddler. All the razor script I have to make changes. But, even if I take out all the razor script, I still got that error
– Sat
Oct 9 '13 at 15:55
Set your action to be of type PartialViewResult instead of ActionResult. Also, please show the call to the action, are you using RenderAction?...
– Lars Anundskås
Oct 9 '13 at 15:57