asp.net-mvc-3

asp.net MVC 3 no default page

Has anyone tried to deploy an asp.net mvc 3 website that uses the razor templates? The project does not create a default page and not sure if this changes in some way? ...

Asp.Net-MVC application dying

I have a strange issue with an Asp.NET MVC application. Using Asp.NET MVC 3 Preview 1 on IIS 7.5 - Integrated After building the application everything runs fine. Then after some random amount of time (or sometimes after updating a view or js file) the application dies. Meaning, requesting the root page, I get the 403 error and reques...

ASP.NET MVC 3 Razor performance

I've made a simple hello world project in asp.net mvc2,3 aspx and 3 razor and benchmarked them. What I see is: asp.net mvc 2 aspx : 4200 request per second asp.net mvc 3 aspx : 3200 request per second asp.net mvc 3 razor : 1700 request per second What's wrong with razor, it's so slow? Update: I've redone the test. All 4 test virtual...

Should I write from Controller, Code Behind, or Helper in MVC?

I've seen all the questions and answers around not having code-behind for a view, however I have a case where I need complex logic to generate the presentation (view) layer. I have to output a PDF file based on data obtained from db. Where is the best place to generate this PDF and write to the response stream? Doing response.write fr...

Does ASP.NET MVC 3 Preview 1 (or the eventual RTM) supports .NET 3.5

I've been looking for information regarding if the third version of ASP.NET MVC will support .NET 3.5 or not. I haven't been able to find anything that either confirms it or denies it. ...

Nested operations with Razor View Engine

I cannot figure out how to do "nested" operation in Razor. For example how to use IF inside FOREACH. VisualStudio throws compile-time error on following block, saying "Invalid expression term 'if' " @foreach (var document in Model) { @if (document.Item.Count > 0) { <div> @MvcHtmlString.Create(document.Items[0].C...

Razor syntax @using and namespace declarations fail

Is there some sort of magic I need to use to get the namespaces in the pages/namespaces element in the webconfig? <pages> <namespaces> <add namespace="System.Web.Mvc"/> <add namespace="System.Web.Mvc.Ajax"/> <add namespace="System.Web.Mvc.Html"/> <add namespace="System.Web.Routing"/> <add name...

Why does the generated NinjectMVC3.cs from NuPack not compile? (or what happened to MvcServiceLocator in ASP.NET MVC 3 Beta? )

Using the NuPack addin and installing the NInject MVC 3 package results in the following compile error in the generated NinjectMVC3.cs file. The name 'MvcServiceLocator' does not exist in the current context The sample video David Ebbo posted shows it working just fine at 09:43. Here is the currently generated class: public class Nin...

Why is EF4 trying to re-create my database even though the model hasn't changed?

I have an ASP.NET MVC 3 Beta website using SQL Server CE 4.0. With both ScottGu's NerdDinner example and my own code, I will sometimes get the following exception as soon as I try to access the database: File already exists. Try using a different database name. [ File name = D:\Sourcecode\NerdDinner\NerdDinner\App_Data\NerdDinners.sdf...

Asp.net MVC 3 inject UserControl for TemplateHint

Is it possible to somehow leverage the dependency injection in Asp.net MVC 3 (using the Forms ViewEngine) to inject UserControls from another library? I am already using MEF to load some other stuff into my MvcApplication. I need this because I want to build a system with an expandable type system. I want the type vendor to be able to ...

ASP.NET MVC 3 Beta 1 Block Access to Razor views

Is there a way to block access (404) to the Razor views in MVC 3 beta 1? When I create a brand new blank site (IIS7) and then access /views/home/index.cshtml from the browser, instead of the 404 I get this [InvalidCastException: Unable to cast object of type 'ASP.Index_cshtml' to type 'System.Web.IHttpHandler'.] System.Web.WebPag...

New project for ASP.NET MVC 3 Beta not including unobstrusive validation Javascript files

My problem today is rather simple, but its driving me nuts! I just downloaded and installed the ASP.NET MVC 3 Beta and created a new project using VS 2010. But when I check the scripts folder, there are none of the following files there! (from what I understood, they should be there): · /Scripts/jquery.unobtrusive-ajax.js · /Scripts/jq...

Unity IoC and MVC 3 Beta - Passing IRepository to Controller Constructor

Did something change in MVC 3? I have tried all the examples on the Internet for setting up Unity as my IoC Container, but I keep getting an error saying that Unity cannot resolve my UserController. Here is my constructor on my UserController: public UserController(IUserService userService) { _userService = userService; } I have...

Difference in Forms Authentication between Razor Preview and Razor Beta?

I'm attempting to upgrade an MVC project to Beta using Razor (from the Preview release) and am now experiencing strangeness with Razor not going to my login view that it use to go to (when someone asks for an action that required authorization). My web config has <authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" tim...

What's the base class of a Razor View in ASP.NET MVC3

I'm trying to have all my views inherit from a custom class so that I can add certain behaviour and values to all pages, but I'm having some issues. I tried subclassing System.Web.Mvc.WebViewPage but I'm forced to implement an Execute procedure that I don't know what it should do. Also, if I try to access the Context variable, I get a nu...

Multiproject areas in ASP.Net MVC 3

Does any one have any idea about multiproject area support in asp.net mvc 3? As it was degraded to future status in mvc 2. If it is still not included then should we look forward for ASP.Net MVC Portable Areas via MvcContrib. Can you share your expreriences? What are the recommended way for managing a large application? I read about MEF...

Complications when upgrading from ASP MVC 3 Preview 1 to beta

I have just upgraded my ASP MVC 3 application from the preview to the beta version. In preview everything worked fine, but as soon as I upgraded weird things started to happen. I get this error message: Compiler Error Message: CS0234: The type or namespace name 'Helpers' does not exist in the namespace 'System.Web' (are you mi...

Entity Framework -- How to set properties to special types

Hi All, I'm new to MVC and Entity Framework, so this may be a relatively simple answer, but I've tried searching around so far and no luck. I'm using the most recent versions of both tools to my knowledge (MVC 3 Beta and Entity Framework 4.0) I'm just trying to set up a quick example. Logically, I'm dealing with events -- in this case...

Where should I place Declarative HTML helpers in ASP.NET MVC 3

I'm trying to make a declarative HTML Helper as specified in ScottGu's Razor post, but I'm not having much luck. I tried putting a Helpers.cshtml file with a DateTimeHelper in Views/Helpers but it wouldn't pick it up, so I tried in App_Code as per the MVC 3 Beta post. Now it picks it up, but when I try to use it in a file like so: @Date...

ASP.NET MVC: logic in _layout.cshtml that takes variables from a given controller

Hi all, New to MVC so forgive me if the terminology is a little off. I'm using ASP.NET MVC3 beta and VS 2010. I'm not sure if this is an error of concept, of syntax, or what. Essentally, what I'd like to do is, for _layout.cshtml, I would like to include the jQuery script for any Controller whose ActionResult sets ViewModel.UseJQuer...