I want to pass a string object into a View:
<%@ Page Title="" Language="C#"
MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<String>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2><%=Model %></h2>
</asp:Content>
When I try this:
return View("SomeView", "stringToPass");
the error occurs: The view 'SomeView' or its master was not found.
but, when I change the return to
return View("SomeView");
everything works fine. So how to pass that string ?
its confusing it with another overload of View(), do:
return View("SomeView", (object)"stringToPass");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With