asp.net-mvc-2

What is the feature you like best in ASP.Net MVC 2.0?

ASP.Net MVC 2.0 will be released in a few months. There are some bug fixed and some new features. Which feature is more useful for you and you will use more? ...

MVC2: "File not found" after view is painted

This is wierd. First, I'm building a site based on someone else's framework (Piers Lawson: Creating a RESTful Web Service using MVC ), so I'm not entirely sure what's going on under the covers. But when I run it in VS 2010 by pressing F5, it brings up the Home page, and THEN traps an error in Application_Error. The error is "File does...

MVC view can't find my extension method

I've created an extension method: namespace MyComp.Web.MVC.Html { public static class LinkExtensions { public static MvcHtmlString ActionImageLink(this HtmlHelper htmlHelper, string linkText, string imageSource, string actionName) { ... } } } I've referenced the assembly from my mvc app,...

MVC.NET Html Helper similar to Url.Action() for encoding _only_ the route parameters

With MVC.NET I can use Url.Action() to generate a raw URL that includes the controller and the action and the route parameters. Example: <%= Url.Action("Edit", new { customerId=Model.id }) %> Produces: /Customer/Edit/123 However, I do not see a helper to simply encode the route portion only, which would be customerId above, like th...

Redirect problem

I have this code in the client side: $.post('<%=Url.Action("Action_Name","Controller_Name")%>', { serverParam: clientParam}, null, null); And this code in the server side: [HttpPost] public ActionResult Action_Name(string serverParam) { return View(); } I currently am in a view and when i click a button i want to be redirected ...

Get posted selected item from DropDownList in ASP MVC

Controller public ActionResult Create() { return View(new PageViewModel()); } [HttpPost] public ActionResult Create(Page page) { try { repPage.Add(page); repPage.Save(); return RedirectToAction("Edit"); } catch { return View(new PageViewModel()); } } PageViewModel public class PageViewM...

How to supress re-post when refreshing a page - ASP.NET MVC

hi all, I am building a wizard using asp.net mvc. currently when the user hits next (or previous) the form values are posted to an action which does any processing required and then renders the next view. the problem i am having is that if the users hit refresh in that new view they get prompted to re-post the form values which causes...

Link to a root controller from area controller in ASP MVC

How can I link to one of my root controllers from one of my areas? <% Html.RenderAction("Action", "Page", new {area = "root", name = "Admin"}); %> This gives me an error: No route in the route table matches the supplied values. I have a controller named Pagein a folder named Admin in my root controller collection. I can reach th...

Create reusable 'base code' using MVC2-RC?

I am trying to write a simple library for MVC2 projects that takes care of user login, e-mail validation, password recovery, etc. Since some of these steps involve user interaction, I need to have Views and Controllers in that project. In MVC2 Preview 2, one could do this by abusing areas (at least, it seems) since they were implemente...

Removing master layout from view (MVC2)

Hi, if i need remove master layout from my view, how can i do it in MVC2? i tried put code in my view that was shown in documentation http://sparkviewengine.com/documentation/master-layouts: , but it still bring my Application.spark layout :-/ any ideas why? ...

Database connection string and collation

Is it possible to set connection collation within MySql connection string and how, since there's a default setting on the server that's used for new connections. Two things I can't do: Can't call SET COLLATION_CONNECTION after I open a connection, because I'm using Entity Framework that does all the calls for me not entirely true as y...

ASP.NET MVC - Data Annotations - Why add a default RequiredAttribute?

Can anyone explain why it is assumed that a non nullable type property should always have a RequiredAttribue? I am trying to write a label helper that will auto append * or change the css class so that I can indicate to the user that the field is required. However when querying the metadata the non nullable properties end up with a req...

Asp.Net MVC - Common Data Across All Controllers

The setup: (using Asp.Net MVC 2 RC, Entity Framework, SQL Server, VS2008) My buddy and I are working on a project that will have different domains pointing at it. We want to get the domain (website) out of the Request and use that to drive data. This website data needs to be part of all the controllers. Ex. Data for domain1.website...

ASP.NET MVC 2 Custom editor templates for splitting datetime fields

In the site I am building I need to have datetime properties split into different combinations depending on the property. Examples: Member view has date of birth property which needs to be shown on the view as seperate day/month/year dropdowns. A credit card view has an expiry date property which needs to be shown as seperate month/ye...

VS 2010 beta 2: ASP.NET MVC2 project cannot add Areas

I have installed VS 2010 beta 2 on my Vista Home Premium 64-bit edition laptop. I was so excited on MVC 2 but to my disappointment, I cannot add Areas to the MVC 2 project. Anywone experiencing this too? Or is it only me? I would love to hear some info / walkthrough on how to fix this problem. Thanks! EDIT: added screenshot ...

ASP.NET MVC : strange POST behavior

ASP.NET MVC 2 app I have two actions on my controller (Toons): [GET] List [POST] Add App is running on IIS7 integration mode, so /Toons/List works fine. But when I do POST (that redirects to /Toons/List internally) it redirects (with 302 Object Moved) back to /Toons/Add. The problem goes away if I use .aspx hack (that works ...

Can't set up asp.net mvc 2 RC and spark view engine

Hi 2 all, Does omebody has ideas how to fix "Method not found: 'Void System.Web.Mvc.ViewContext..ctor(System.Web.Mvc.ControllerContext, System.Web.Mvc.IView, System.Web.Mvc.ViewDataDictionary, System.Web.Mvc.TempDataDictionary)'." exception. This solution doesn't work http://dotnetslackers.com/articles/aspnet/installing-the-spark-view-e...

How to set a Default Route (To an Area) in MVC

Ok this has been asked before but there is no solid solution out there. So for purpose of myself and others who may find this useful. In MVC2 (Asp.net) I want it so when somone navigates to the website, there is a default area specified. So navigating to my site should send you to ControlerX ActionY in AreaZ. Using the following route ...

LINQ to SQL defining Where class depending on parameters

return (from s in db.StudentMarks where s.Class == Class && s.Year == Year // this line orderby s.Year, s.ExamType select new StudentAddMarks() { --Obj }).ToList(); I am going to return an Object depending on the Class and Year params. ...

ASP.Net MVC 2 RC: How To Use Client Validation with Data Annotations for Lists?

My problem: I can't get Data Annotations Client Validation to work with a List in my viewdata class. The skinny: In my view data class I have a List. public class FriendsViewData { public List<Person> people { get; set; } } I have all the properties of the class Person as required using Data Annotations. public class Person ...