Вопрос по .net, asp.net, asp.net-mvc-3 – Передача данных на страницу макета

7

Error: User Rate Limit ExceededlayoutError: User Rate Limit Exceeded

@ModelType KarateAqua.schoolModel

<html>
    <body>

        @RenderBody()

        <div id="footer">
            <div class="content">
                <div class="bottom_logo">
                    <a href="/"><span class="inv">@Model.schoolName</span></a>
                </div>
            </div>
        </div>
    </body>
</html>

Error: User Rate Limit ExceededActionResultError: User Rate Limit ExceededlayoutError: User Rate Limit Exceeded

Error: User Rate Limit Exceededstackoverflow.com/questions/13225315/… DeeArgee

Ваш Ответ

7   ответов
2

Error: User Rate Limit ExceededViewBagError: User Rate Limit ExceededViewDataError: User Rate Limit Exceeded

Layout

<html>
<body>
@RenderBody()

<div id="footer">
<div class="content">
<div class="bottom_logo">
<a href="/"><span class="inv">@ViewBag.schoolName</span>
</div></div></div>
</body>
</html>

Controller

public ActionResult Index(){
   ViewBag.schoolName = "Bayside Tigers";
   return View();
}
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded Jeremy Lewallen
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
7

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

@model KarateAqua.schoolModel

<div class="bottom_logo">
<a href="/"><span class="inv">@Model.schoolName</span>
</div>

Error: User Rate Limit Exceeded

public class SchoolController : Controller
{
     public ActionResult Index()
     {
          //get schoolModel  
          return PartialView(schoolModel);
     }
}

Error: User Rate Limit Exceeded

@Html.Action("Index","School")
1

Error: User Rate Limit ExceededHTTP SessionError: User Rate Limit Exceeded

//Opening page controller
public ActionResult Index()
{    
    Session["something"]="xxxx";
    return View();
}

Error: User Rate Limit Exceeded_layoutError: User Rate Limit Exceeded

//persistent data   
<p>Hello, @Session["something"]!</p>

Error: User Rate Limit Exceeded

14

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

public class CurrentUserAttribute : ActionFilterAttribute
{
    public override void OnResultExecuting(ResultExecutingContext filterContext)
    {
        // Don't bother running this for child action or ajax requests
        if (!filterContext.IsChildAction && !filterContext.RequestContext.HttpContext.Request.IsAjaxRequest())
        {

            if (filterContext.HttpContext.Session != null)
            {
                var currentUser = filterContext.HttpContext.Session["CurrentUser"] as CurrentUser;
                if (currentUser != null)
                {
                    filterContext.Controller.ViewBag.CurrentUser = currentUser;
                }
            }
        }
    }


}
Error: User Rate Limit Exceeded
4

Error: User Rate Limit Exceeded

@{
    KarateAqua.schoolModel data = YourBusinessLayer.Method();
}

<html>
<body>

    @RenderBody()

    <div id="footer">
        <div class="content">
            <div class="bottom_logo">
                <a href="/"><span class="inv">@data.schoolName</span></a>
            </div>
        </div>
    </div>
</body>
</html>
Error: User Rate Limit Exceeded
1

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededlayoutError: User Rate Limit Exceeded

<html>
    <head> 
    </head>
        <body>
            @{ Html.RenderAction("header", "MyController", new { area = "" }); }

            @RenderBody()
//...
1

Your Layout Page:

@ViewBag.LayoutVar

Your HomeController:

public class HomeController : BaseController
{
   //Here some logic...
}

Your BaseController

namespace ProjectName.Controllers
{
    public class BaseController : Controller
,    {

        public YetkiController()
        {
            //This parameter is accessible from layout
            ViewBag.LayoutVar = "Suat";
        }
    }
}

Error: User Rate Limit Exceeded(Like username or other data based parameters)

Error: User Rate Limit ExceededBaseControllerError: User Rate Limit Exceeded

Похожие вопросы