I have a MVC3 project using Area in it.the struct of web site si ' top - middle - bottom'the middle layer is divided into left and right partat the left part , I want to write codes as public to use, but '_ViewStart.cshtml' in the Area it's point to the '_Layout.cshtml' file at '~/Views/Shared/' my problem is how to use another cshml file as '_Layout.cshtml'
In the default ASP.NET MVC 3 project, layout & partial cshtml files start with an underscore (eg. _viewstart, _Layout, _LogOnPartial). Why? Does the framework give some special meaning to a cshtml file that begins with an underscore?
I'm attempting to access a layout page in an MVC page like this:
[Code]....
The problem is that I get this error:
he layout page "/Shared/_Layout.cshtml" could not be found at the following path: "/Shared/_Layout.cshtml".
Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: The layout page "/Shared/_Layout.cshtml" could not be found at the following path: "/Shared/_Layout.cshtml".Source Error:
[Code]....
Stack Trace:
[Code]....
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
Not sure why this is a problem, I was referencing this page:
After creating a Empty Template based website with a default .cshtml, I am unable to run the web page using webmatrix beta 3. Following error message I have : Server Error in '/' Application. Specified argument was out of the range of valid values. Parameter name: site Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: site Source Error:
[Code]....
Stack Trace:
[Code]....
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
I am building a site with WebMatrix using the razor syntax in .cshtml files. However I'm stumped as to how I can use the normal set of asp.net controls that are found in the toolbox in Visual Studio - eg: calendar, panel, radio button list etc... Is it possible to use these or can you only use Helpers with razor?
How can i directly access a .cshtml file in ASP.NET MVC using razor view engine?
For example i have this url: localhost/Home/About. This will load the about site inside the "master" page.
I want to load the about page without also loading the master page. So i was thinking that i could use this url: localhost/Home/About.cshtml. But it's not working.
How can i load a view page without loading the master page?
I'm doing something wrong, but for the life of me can't figure out what. (Maybe it's all the beta software I'm using to build this website ;-) )I'm trying to use the Facebook helpers, which use the WebMatrix.Data and WebMatrix.WebData libraries. These work fine from my class files, but apparently I can't use them in my .cshtml files.Anybody run into this? Alle references to classes in these libraries break my site (not my build btw?). And yes, they are referenced.
I would like to use the _ViewStart page to set the master page (layout) used by the views. I have only two different layouts. One for the homepage and one for the other pages (but that may change)I was hoping to add a dynamic property to the ViewModel object in the home page's controller method and then check for it. Something like this_ViewStart =
I'm new to ASP.NET. I'm making a session counter, which is incremented in the Session_Start() event and decremented in Session_End(). I have created a Global.asax file and added the event handlers. Then I wanted to access the Application object in a .cshtml file, but the Application object is not available. It's underlined with a red squiggly line.
I'm learning to use webmatrix via the tutorials on the website. I've had success with all table operations, when only using one table. I'm using the following address to access the site uredi_let_padalce.cshtml?LetId=4 and the is code:
[Code]....
The page works if I write: where LetId=4 instead of @0. But if I leave the variable I get the following error: The column name cannot be resolved to a table. Specify the table to which the column belongs. [ Name of ambiguous column = LetId ] If I specify the table name LetId_PadalecId. LetId=@0, then I get the parameter missing error. How could I tell the server which LetId I want?
I have been struggling to get WebMatrix to serve any cshtml files. I performed a fresh install of WebMatrix, then started a tutorial which involves creating one small cshtml file. Whenever I try to run the site, I get the following error:
This type of page is not served.
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect. review the URL below and make sure that it is spelled correctly.
Requested URL: /Home.cshtml
I tried reinstalling to no avail.
I am running Windows 7 Pro, with IIS 7 installed. (IIS Express is supposed to be able to run side-by-side no problemo)
In my application users can write their own 'templates'. That are filled with data from other sources. I could use a simple token replacement, but I would like to be able to use the Razor syntax and engine for rendering the template. Here is an overly simplified example:
[Code]....
Before you point to the following sources I will clarify what I have learned from them:RazorEngine (http://razorengine.codeplex.com/). This code compiles the string into a class, then a dll, then finally reads from a dll - all this to bypass the MVC engine. I don't want to do that because I am in MVC and don't want the additional overhead.The following blog shows how to do this for one of the MVC 3 pre-releases:http://buildstarted.com/2010/09/28/mvc-3-razor-view-engine-without-a-controller/ I cannot get it to work with MVC 3 RTM. When I take the exact code (and replace the CshtmlView with a RazorView) I end up with the error: The method or operation is not implemented. It appears to have something to do with @Model.Name, and being unable to find "Name".A comment in the blog elludes to a statement from ScottGu that the RTM would allow this functionality from the get go. I cannot find this blog.
This question appear when I worked with partial view (MVC3/Razor), but I am sure - it's clear Razor Syntax question, not related direct to partial view. So - I have partial view Menu.cshtml with full markup as:
@model IEnumerable<SportsStore.WebUI.Models.NavLink> @foreach(var link in Model) { @Html.RouteLink(link.Text, link.RouteValues); }
No problem - "parent" view call it @{Html.RenderAction("Menu", "Nav");} and all work as magic. But, if I will edit the Menu.cshtml as:
@model IEnumerable<SportsStore.WebUI.Models.NavLink> @foreach(var link in Model) { Html.RouteLink(link.Text, link.RouteValues); }
(see - NO '@' before Html.RouteLink!) all just broke: now @{Html.RenderAction("Menu", "Nav");} output is totally empty, no one HTML tag. Want to know - what is the difference between two piece of code? I assume @ before foreach also automatically "drop into" and apply to Html.RouteLink as well? So - am I wrong?
I manage a large asp.net site which has previously been converted from static html site to asp.net. For several reasons (mainly SEO) we decided not to rename all the files to .aspx back when we originally converted the site. This was very easy to do by simply adding the buildProvider and httpHandler to the web.config.
Now I am upgrading the site to use Asp.net WebPages with Razor cshtml files. I can rename all the files if necessary, and use url rewriting to make the urls stay the same, however it would be much easier if I could just configure the web.config to tell it to parse .html files as if they were .cshtml. I have searched around quite a bit, and could not find anything equivalent to the PageHandlerFactory for razor pages. It appears as though it is just an internal mechanism in the .net 4.0 ISAPI handler.
The site is currently running on Windows 2003 server and IIS 6. We will be upgrading to 2008/IIS 7.5 in the near future, but I'd prefer not to wait for that. Is there any way to get the .html files to be parsed by razor as if they were .cshtml files?
Now i am learning mvc3 razor. I create a razor mvc project and set a vitural webapp in IIS7 for it , as "localhost/mvc3/". When i do some changes on .cshtml trying to check effects I just find that corresponding page doesn't change even refresh browser. I am not quit familar with the rule & principle on this.
BTW : this post page seems have severe problem because I cannot use the message editor in Chrome / IE9beta : they just leave a stubborn blank area for me.
There I was, happily coding webpages, when suddenly it wouldn't run them anymore. Now when I click run I get an error message that looks like this: Server Error in '/' Application.This type of page is not served. Description:The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Requested URL: /quiz/intro.cshtml Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
When i created a simple site via Matrix which adopts Razor technology by default, i found site automatically display "default.cshtml" if started through "http://localhost:xxxx/bread/" ; however i hadn't set "default.cshtml" as "default document" for this site, even i seek in the "applicationhost.config" i just find