asp.net-mvc-2

How do I call reference of Model in viewpage located outside the view folder

I have created Viewpage outside the view folder and for that viewpage calling Model located inside the Model folder. but it is giving the error , I have also imported the namespace of Model . ...

Proxy object references in MVC code

Hi there, I am just figuring out best practice with MVC now I have a project where we have chosen to use it in anger. My question is. If creating a list view which is bound to an IEnumerable is this bad practise? Would it be better to seperate the code generated by the WCF Service reference into a datastructure which essentially hold...

Return HTTP 404 when MVC2 view does not exist

Hi, I just need to have the a small CMS-like controller. The easiest way would be something like this: public class HomeController : Controller { public ActionResult View(string name) { if (!ViewExists(name)) return new HttpNotFoundResult(); return View(name); } private bool ViewExists(string na...

Test Views in ASP.NET MVC2 (ala RSpec)

Hi, I am really missing heavily the ability to test Views independently of controllers. The way RSpec does it. What I want to do is to perform assertions on the rendered view (where no controller is involved!). In order to do so I should provide required Model, ViewData and maybe some details from HttpContextBase (when will we get rid ...

MVC 2 Area Authentication Not Working

Using MVC 2, if I setup my root web.config with forms authentication (there is no locations section), and I go to a page outside an area (off of the root), I get redirected to the login page as one would expect. However, if I go to a page in an area, I don't get redirected as expected. Do I need an additional web.config somewhere in th...

Entity Framework 4 - Calling a Select / Paging Stored Procedure

Hi guys and girls, I am just starting out with the Entity Framework 4.0 and ASP.NET MVC 2 and have a few questions regarding the use of stored procedures and paging. You can map the Insert, Update, and Delete actions to stored procedures and I have already done this. However for my paging to work I need to map the Select action. Now ...

Handling MVC2 variables with hyphens in their name

I'm working with some third-party software that creates querystring parameters with hyphens in their names. I was taking a look at this SO question and it seems like their solution is very close to what I need but I'm too ignorant to the underlying MVC stuff to figure out how to adapt this to do what I need. Ideally, I'd like to simply r...

An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll

Ok the thing is that I am using asp.net mvc with linq to sql. I have a scenario where there are two tables group and features with many to many relationship with the third table groupfeatures. I have drag and drop all three table in the dbml file. The thing is that it runs fine with group but when I call the Feature things the above err...

Castle Windsor Controller Factory and RenderAction

I am running into an issue when using my Castle Windsor Controller Factory with the new RenderAction method. I get the following error message: A single instance of controller 'MyController' cannot be used to handle multiple requests. If a custom controller factory is in use, make sure that it creates a new instance of the controller f...

Intermittent error thrown, "A required anti-forgery token was not supplied or was invalid."

I'm occasionally getting this error during normal use, and I've not found a way to stop it without removing the attribute that requires the token, which I'd rather not do. I've gotten this bug during my own testing (but seemingly randomly) and I know from my logging that actual logged-in users are getting it as well. Does anyone know...

Converting From Castle Windsor To StructureMap In An MVC2 Project

I am learning about best practices in MVC2 and I am knocking off a copy of the "Who Can Help Me" project (http://whocanhelpme.codeplex.com/) off Codeplex. In it, they use Castle Windsor for their DI container. One "learning" task I am trying to do is convert this subsystem in this project to use StructureMap. Basically, at Application_...

ASp.Net MVC routing

Hi, I am using MVC 2.0 to create my application,my problem i s related to the routing. Actually in my application each user have required seperate subdomain,like www.example.com/user1/ ,www.example.com/user2/ ...etc.the default domain is www.example.com.So how can i make it possible with routing in mvc. i have tried like thi...

How to binding to bit datatype in SQL to Booleans/CheckBoxes in ASP.NET MVC 2 with DataAnnotations

I've got problem with binding data type boolean to checkbox in MVC 2 data annotations Here's my code sample: label> Is Hot </label> <%=Html.CheckBoxFor(model => model.isHot, new {@class="input" })%> It always raise this error message below at (model=>model.isHot). Cannot convert lambda expression to delegate type 'System.Func<Framew...

asp.net mvc checkbox hierarchy

I want to create a checkboxes hierarchy like this in mvc2.How would I be able to achieve this in the most simplest manner.I have done this with tree in traditional forms .Beside Each field there is a checkbox. If I want to Assign Manage User and Manage Feature to the Administrator I will checked the checkboxes press submit and then the f...

Jquery-UI tabs : Double loading of the default tab

I use jqueryui-tabs to display a tabbed UI. here is how my markup looks in a MasterPage: <div id="channel-tabs" class="ui-tabs"> <ul class="ui-tabs-nav"> <li><%=Html.ActionLink("Blogs", "Index", "Blog", new { query = Model.Query, lang = Model.SelectedLanguage, fromTo = Model.FromTo, filters = Model.FilterId }, new{ title="Bl...

HTML Encoding Blocks - Invalid expression term ':'

Hey everyone, I'm developing a new ASP.NET MVC 2.0 application and wanting to use the new ASP.NET 4 encoding blocks. My View code contains <%: Model.ActivityName %> however Visual Studio is reporting: Unexpected token at the position of the : (colon). When I run the application I get the following compilation error: Compile...

asp.net mvc 2 multiple partial view

Hey Guys, I have a contoller that renders 3 different views. But I also have a common part (div) for every view. I thought that I can create an UserControl with own controller and include that control on my views (New controller and view as controll). How should I use that UserControl? Should it be a partial view? Or different approach...

What is the web.debug.config and web.release.config file for?

Hi, I just upgraded to VS 2010 and MVC 2.0 and I noticed the web.config has two additional files attached to it? Are thee files used to specify debug and release specific settings, so you don't clutter up the main web.config? Does it even make sense to place a connection string in the root web.config file if I have have a local and remo...

Custom Html Helper is not working in asp.net MVC 2.0

Hey I was using this custom html helper in asp.net mvc 1.0 but now I am trying to use it in a 2.0 project and it crashes http://blog.pagedesigners.co.nz/archive/2009/07/15/asp.net-mvc-ndash-validation-summary-with-2-forms-amp-1.aspx This is the error I get. System.MissingMethodException was unhandled by user code Message=Method not...

Problem displaying custom error page in ASP.NET MVC 2

This is customErrors section from my web.config file <customErrors mode="On"> <error statusCode="500" redirect="HTTP500.aspx" /> </customErrors> HTTP500.aspx is the same as standard /Views/Shared/Error.aspx page. When I get HTTP 500 error I see this page: Server Error in '/' Application. Runtime Error Description: An application...