MVC :: Use Another _Layout.cshtml?

Mar 19, 2011

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'

View 4 Replies


Similar Messages:

MVC :: _layout.cshtml - Find The Name Of The View And/or Controller?

Feb 23, 2011

There is a way to find, from the _layout.cshtml (Razor engine) to find the name of the view that it is displayed currently?( the one that is in

@RenderBody())
There is a way to find, from the _layout.cshtml (Razor engine) to find the name of the controlller that it is displayed currently?

View 7 Replies

Razor _layout.cshtml Have A Leading Underscore In File Name?

Jan 2, 2011

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?

View 4 Replies

MVC :: Error - The Layout Page "/Shared/_Layout.cshtml" Could Not Be Found At The Following Path....

Mar 15, 2011

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:

[URL]

View 3 Replies

MVC :: Common _Layout For All Areas?

Feb 7, 2011

Where should I put my common _layout.cshtml file for all of my Areas?

View 4 Replies

WebMatrix :: Unable To Run .cshtml In Beta 3

Dec 2, 2010

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

View 1 Replies

WebMatrix :: How To Use C# Class From Cshtml File

Jul 19, 2010

I am new to ASP.NET, I would like to know how to create C# class in seperate file and using it in cshhtml file.

View 5 Replies

Using Controls In WebMatrix Cshtml Pages?

Mar 11, 2011

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?

View 2 Replies

MVC :: Directly Access .cshtml Page?

Feb 9, 2011

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?

View 2 Replies

MVC :: WebMatrix From Cshtml Files In Visual Studio?

Dec 16, 2010

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.

View 6 Replies

MVC :: _ViewStart.cshtml And Conditional Layout Pages?

Nov 30, 2010

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 =

[Code]....

And in the HomeController Index() add this

ViewModel.IsHomePage = true;

View 2 Replies

Application Object Isn't Visible In Cshtml Page

Jan 20, 2015

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.

View 2 Replies

WebMatrix :: And Databases To Access The Site Uredi_let_padalce.cshtml

Jan 18, 2011

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?

View 2 Replies

WebMatrix :: IIS Express Refuses To Serve .cshtml Pages?

Feb 24, 2011

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)

View 8 Replies

MVC :: Running A String Through The Razor Engine Instead Of A Cshtml File?

Mar 29, 2011

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.

View 10 Replies

MVC 3 Razor Syntax - Partial View Menu.cshtml With Full Markup

Mar 27, 2011

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?

View 2 Replies

Can Server .html Files Using Razor As If They Were .cshtml Files Without Changing The Extension Of All My Pages

Feb 24, 2011

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.

<buildProviders>
<add extension=".html" type="System.Web.Compilation.PageBuildProvider"/>
</buildProviders>
<httpHandlers>
<add path="*.html" verb="*" type="System.Web.UI.PageHandlerFactory"/>
</httpHandlers>

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?

View 2 Replies

MVC :: When Auto Format Cshtml Files (Ctrl+K, Ctrl+D), The {} Of An If/foreach/for Don't Line Up Under The @if Correctly?

Nov 9, 2010

When I auto format cshtml files (Ctrl+K, Ctrl+D), the {} of an if/foreach/for don't line up under the @if correctly

[Code]....

instead of

[Code]....

Is this being fixed? Just a note that in my small example, it isn't bad. But if the @if is really indented, the braces are way far to the left.

View 2 Replies

MVC :: Live Pages Don't Change After Changing "cshtml" ?

Jan 27, 2011

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.

View 5 Replies

WebMatrix :: Webmatrix Refuses To Run Cshtml Pages?

Feb 15, 2011

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

View 3 Replies

WebMatrix :: Why Is "default.cshtml" Automatically Recognized As Default Page In IIS Express Server

Feb 4, 2011

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

<defaultDocument enabled="true">
<files>
<add value="Default.htm" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="index.html" />
<add value="iisstart.htm" />
<add value="default.aspx" />
</files>
</defaultDocument>

which apparently hasn't "...cshtml" yet. So I am wondering now why in this case the web server actively sets "default.cshtml" as default start page ?

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved