Layout page :_MyLayout.cshtml

<!DOCTYPE html>
@*Razor Layout page *@
@*HTTP Header protocol for , Prompt the browser for the character set used by the web page (GB2312: Simplified Chinese |BIG5: Traditional Chinese |iso-2022-jp: Japanese |ks_c_5601: Korean |ISO-8859-1: english |UTF-8: Universal language coding )*@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> @* Set the expiration time of the web page . Once the page expires , Must be retransmitted to the server . You have to use GMT Time format of .*@
<meta http-equiv="expires" content="Fri,12 Jan 2001 18:18:18 GMT"> @* Prevent browsers from accessing page content from the local computer's cache , Visitors will not be able to browse offline .*@
<meta http-equiv="Pragma" content="no-cache"> @* Automatically refresh and point to a new page , Among them 2 It means staying 2 Seconds later, it will automatically refresh to URL website .*@
<meta http-equiv="Refresh" content="200;URL="> @* If the page expires , So what's on file cookie place it on clipboard . You have to use GMT Time format of .*@
<meta http-equiv="Set-Cookie" content="cookievalue=xxx;expires=Friday,12-Jan-2001 18:18:18 GMT;path=/"> @* Force the page to display as a separate page in the current window , Prevent others from calling their own pages in the framework .*@
<meta http-equiv="Window-target" content="_top"> @* Set page display language *@
<meta http-equiv="Content-Language" content="zh-cn" /> @*W3C Web specifications , Indicates the type of script in the page .*@
<meta http-equiv="Content-Script-Type" content="text/javascript"> @* Specifies whether to display the Picture toolbar *@
<meta http-equiv="imagetoolbar" content="false" /> @* Only IE8 And above IE Browsers can recognize , Force kernel conversion (IE=7: With IE7 Engine to render the page |IE=edge: With the highest version IE To render a page |chrome=1: Can activate Chrome Frame)*@
<meta http-equiv="X-UA-Compatible" content="IE=7"> @* Mobile device display parameters (width: Visual width ,height: But the height ,user-scalable: Allow zoom or not ,intial-scale: Initial zoom level ,maximum-scale: Maximum zoom level ,minimum-scale: Minimum zoom level )*@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> @* Page width is set width , The initial zoom is 100%*@ @* Set page keywords for search engines *@
<meta name="keywords" content=" Hefei ,Test"> @* Set the main content of the page for the search engine *@
<meta name="description" content=" This is a test page ."> @* Tell the search engine which pages the robot grabs .(all: The file is retrieved , Page links can be queried |none: Files are not retrieved , Page links cannot be queried |index: Documents will be retrieved |follow: Page links can be queried |noindex: Files are not retrieved , Page links can be queried |nofollow: The file is retrieved , Page links cannot be queried )*@
<meta name="robots" content="none"> @* Explain the author information of the website *@
<meta name="author" content="Ariter,13855505090"> @* Description of the website production software *@
<meta name="generator" content="VS2013" /> @* Explain the copyright information of the website *@
<meta name="COPYRIGHT" content=" Information parameters "> @* Website revisit ,7days representative 7 God *@
<meta name="revisit-after" content="7days"> @* Website character encoding *@
<meta charset="utf-8" /> @* The page title , according to body Page dynamic display *@
<title>@ViewBag.Title - my Razor page </title> @* Reference external scripts and styles *@
<script src="@Url.Content("~/Scripts/jquery-1.10.2.min.js")"></script>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" /> @* quote BundleConfig The style and script package path of *@
@Scripts.Render("~/bundles/modernizr") @* Define the node : Render the corresponding node of the content page ( Only in the layout page ,required: Whether the node must exist in the content page )*@
@RenderSection("myhead", required: false)
<div class="navbar">
<div class="container">
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink(" Home page ", "Index", "Home")</li>
<li>@Html.ActionLink(" About ", "About", "Home")</li>
<li>@Html.ActionLink(" Contact information ", "Contact", "Home")</li>
<h2> The layout page introduces the distribution view </h2>
<hr />
@* Define partial views : Render the view page with that name *@
<hr />
@* Defining divisions Action: Call the Action*@
<hr />
@* Define partial views : The view page that renders the path (PageData The ginseng )*@
@RenderPage("~/Views/Test/MyPartial.cshtml", new { Name = "RenderPage- Childish ", Age = 21})
<div class="container body-content">
@* Define subject : Render the body of the content page ( Only in the layout page , Must and only once )*@
<hr />
<p>&copy; @DateTime.Now.Year - my Razor page </p>

Content page :MyPage.cshtml

@* Content page *@
ViewBag.Title = " The page title ";
Layout = "~/Views/Shared/_MyLayout.cshtml"; // Use layout pages
@* Corresponding to the layout page node *@
@section myhead{
} <h2> Content pages introduce distributed views </h2> <hr />
@RenderPage("~/Views/Test/MyPartial.cshtml", new { Name = " Content page - Childish ", Age = 21 })
<hr />
<hr />

Division of the view :MyPartial.cshtml

@model EF6forMysql.Controllers.MyInfo
@if (PageData["Name"] != null)
<span>PageData Parameters :@PageData["Name"] @PageData["Age"]</span>
} @if (Model != null)
<span>Model Parameters : @Model.Name @Model.Age</span>
} @if (ViewData["Name"] != null)
<span>ViewData Parameters :@ViewData["Name"] @ViewData["Age"]</span>


 public ActionResult MyPage()
return View();
} public ActionResult GetMyPartial()
//ViewData Parameters
ViewData["Name"] = "Action- Huang Zai ";
ViewData["Age"] = ;
// Strong type parameters
MyInfo mi = new MyInfo() { Name = "Action- Huang Zai ", Age = };
return View("MyPartial",mi);

cshtml One or two more related articles

  1. 【 problem 】 MVC Of cshtml Call in page JS Method to pass string variable parameters

    [ problem ] MVC Of cshtml Call in page JS Method to pass string variable parameters . [ solve ] Quote variables directly , Such as : <button onclick="deleteProduct('@ ...

  2. [ Memo ] There is no extension for “.cshtml” Registered build provider

    webconfig Middle configuration <compilation debug="true" targetFramework="4.5.1">       < ...

  3. MVC3 Local cache page for PartialCache.cshtml

    MVC3 And so on PartialCache.cshtml The way of local caching , Concrete realization : Create a new one PartialCache.cshtml The page of , Write the following code on the controller : [OutputCache(Durat ...

  4. Amway one MVC It's a good thing ,RazorGenerator.MsBuild, Can compile automatically cshtml file

    In traditional webForm In development , At the time of release , If you choose precompile , It will automatically send all the aspx File compilation , In the released Directory , I can't see aspx The source code of , And because it's precompiled , So every page opens very fast ...

  5. Runtime error : There is no extension for &quot;.cshtml&quot; Registered providers .

    resolvent : One .   stay machine.config or web.config Medium <compilation><buildProviders> Section to register a . Please make sure that the registered provider has ...

  6. VS2015 install mvc4 Installation package and vs2010 sp1 After that Razor Syntax failure code is not highlighted ( Normal operation )/ The view page can't intelligently prompt (.cshtml) terms of settlement

    VS2015 Default mvc Version is 5.0 above , Creating... Is not supported by default 5.0 The following version . So I want to use mvc 4.0 It can only be installed separately . After searching several tutorials on the Internet, I downloaded them from the official website of Microsoft Visual Studio 201 ...

  7. About VS open cshtml appear Failed to complete the operation . Invalid pointer

    About VS open cshtml appear Failed to complete the operation . Invalid pointer First step : close VS Second parts : Delete %LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModel ...

  8. About learning session One or two of them

    session As a server-side technology , In the web page with cookie They complement each other , Today I learned more about session Knowledge about , Record one or two here , For future reference /* problem : When we browse the web , Zhang San and Li Si can buy ...

  9. PartialViewResult No birds _ViewStart.cshtml

    summary stay ASP.NET MVC in , about Action Obtained in ActionResult If it's a ViewResult object , So it's going on View When presented , It will be executed first _ViewStart.cshtml, And then go to ...

Random recommendation

  1. JSON API Free interface

    come from : E-commerce interface Jingdong gets a single commodity price interface : ...

  2. apache2: Could not reliably determine the server&#39;s fully qualified domain name

    error message :apache2: Could not reliably determine the server's fully qualified domain name, using ...

  3. MySql Update Select nesting

    UPDATE `TB_CM_Dic` SET `ParentID` = (SELECT `ID` FROM (SELECT * FROM `TB_CM_Dic`) AS B WHERE `DicNam ...

  4. note --cocos2d-x 3.0 Environment building

    One . Download resource tools 1. download cocos2d-x 3.0   Official website address : 2. download VS2012 Search the address online ...

  5. Why report a mistake and say req Undefined ,createServer Accept only anonymous functions ?

    var http = require('http');var server = new http.createServer(handlerRequest(req,res));server.listen ...

  6. springcloud( 6、 ... and ): Configuration center ( One )

    As online projects get bigger and bigger , Every project is littered with configuration files , If we adopt the distributed development mode , The number of profiles required increases with the number of services . Some basic service information changes , Will cause a series of updates and restarts , Operation and maintenance is miserable and error prone . To configure ...

  7. Docker Deploy DVWA

    Last time at Docker Manually configured a Ubuntu Of Lamp Mirror image , This time, let's try to deploy a simple web Apply it . First of all, from the Lamp Mirror runs a container root@VM-149-127-debian:~/a ...

  8. webStrom Support Vue

    find webstorm-->preferences-->fileTypes-->html--> add to +-->*.vue

  9. JavaScript For variables and functions in “ advance (hoist)”

    hoist vt. rising , mention ; vi. To be raised or raised ; n. Crane , elevator ; rising ; < Slang > PUSH , Support , for ; This article doesn't speak English , But we can't find a good translation for some English words , List as soon as you come up “hoist” this ...

  10. Javascript The hard bones of : Scope 、 Callback 、 Closure 、 asynchronous ……

    It's time for the myth to break -- This is destined to be a " Invite the humiliation " The blog of , Feige , The God in your eyes ,Duang, This time, he fell face down . The story has to start with this :e.returnValue Report errors : Undefined , ...