asp.net-mvc

Order by with Collate clause | Entity Framework

I don't want to use array sorting on the web server it should be done on SQL server. Microsoft does not support query(in EF) like this: SELECT * FROM [Table_1] ORDER BY [Table_1].field COLLATE SQL_SwedishStd_Pref_Cp1_CI_AS Any ideas? Thank you in advice... ...

How to handle session data in ASP.NET MVC

Let's say I want to store a language_id in the session. I tought I maybe could do something like the following: public class CountryController : Controller{ [WebMethod(EnableSession = true)] [AcceptVerbs(HttpVerbs.Post)] public ActionResultChangelangue(FormCollection form) { Session["current_language"] = form["languagei...

Public method for every view? Default ActionResult and Routes in ASP.MVC

Hi, I'm experimenting with ASP.NET MVC and Routes. It appears MVC forces me to add a public method to the controller any time I want to create a view. For example: public class HomeController : Controller { public ActionResult Index() { return View(); } public ActionResult About() { return View()...

Retrieving Property name from lambda expression

Is there a better way to get the Property name when passed in via a lambda expression? Here is what i currently have. eg. GetSortingInfo<User>(u => u.UserId); It worked by casting it as a memberexpression only when the property was a string. because not all properties are strings i had to use object but then it would return a unary...

Binding application/json to POCO object in asp.net mvc, Serialization exception

I'm passing json back up from my view to my controller actions to perform operations. To convert the json being sent in, to a POCO I'm using this Action Filter: public class ObjectFilter : ActionFilterAttribute { public Type RootType { get; set; } public override void OnActionExecuting(ActionExecutingContext filterContext) { IList<Erro...

MVC - Passing Data with RedirectToAction()

What I'm attempting to do is take the data entered into an MVC user form and submit it back to the user in a different view. I have a private variabled declared in the class: IList<string> _pagecontent = new List<string>(); Here is my action that accepts the FormCollection object, validates it, and tries to pass it on to the "Previ...

Modelstate with Ajax Form

I'm using an AJAX form to update an item to the database. When it gets done, it returns a partial view that re-lists all the items and displays them all in a table. The problem occurs when I have to add a modelstate error in my controller action. I don't want to return the list of items when there is a modelstate error because I want ...

AssemblyInfo versioning ignored in ASP.NET MVC Web App?

Strange one here. My MVC Web Application's version number is not printing correctly to my view according to what is set in AssemblyInfo.cs. The definition I have set in set AssemblyInfo.cs is '1.0.232.0'. I have tried multiple methods in order to print it: <%= System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToStri...

Automated Unit testing for Javascript integrated with CruiseControl, nUnit, nAnt and ASP.net MVC

I work for a team of ASP.net MVC and they are using Cruisecontrol, nUnit and nAnt for the automated testing and build. I am new to the group and i handle the Javascript layer and i am looking for ways to incorporate my work with my teams workflow. Are there any possoble way to do this? Thanks ...

Has ASP.NET MVC made Web Forms a Legacy Platform?

Last week at Mix '09, the final version of ASP.NET MVC 1.0 was released. Some of the stated benefits of this framework are: Clear separation of concerns Testability - support for Test-Driven Development Fine-grained control over HTML and JavaScript Intuitive URLs Now, Microsoft are being careful to tout this as being "...

ASP.net MVC - ViewModel object and Session variables

Say I have the following situation: A paginated View displays a list of contacts with the following route: Contacts/Index/Page/2. The View gets its paginated data ViewModel object. The View also gets its filter properties from the ViewModel, like the Contact Category. I would like to store the page number and the filter properties ...

ASP.NET MVC: The view 'Login' or its master could not be found.

I am attempting to deploy my ASP.NET MVC application to a new environment and I'm running into this error: The view 'Login' or its master could not be found. The following locations were searched: ~/Views/Account/Login.aspx ~/Views/Account/Login.ascx ~/Views/Shared/Login.aspx ~/Views/Shared/Login.ascx I have verified that ~/Views/Acco...

ASP.NET MVC: Unit testing controllers that use UrlHelper

Hello, One of my controllers actions, one that is being called in an Ajax request, is returning an URL to the client side so it can do a redirection. I'm using Url.RouteUrl(..) and during my unit tests this fails since the Controller.Url parameter is not pre-filled. I tried alot of things, among others attempting to stub UrlHelper (whi...

Appending to default title in asp.net masterpage

I am using the MVC to add a title to the masterpage with a content place holder. The default MVC masterpage template uses the following code: <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title><asp:ContentPlaceHolder ID="TitleContent" runat="server"/></title> <link href="../../Content...

Is there an ASP.NET MVC HtmlHelper for image links?

Possible Duplicate: ASP.NET MVC Ajax.ActionLink with Image The Html.RouteLink() HtmlHelper works great for text links. But what's the best way to link an image? ...

Options for asp.net MVC Validation Framework

I'm thinking of two options right now for model-base validation for an ASP.net project I'm starting: xVal (Steve Sanderson's project) and the Enterprise module that Stephen Walther uses on this page I don't really know enough to talk about the preferences as I haven't used either of them yet. Any ideas? Update Using LinqToSql for ORM ...

ASP.NET MVC Service Layer Updates with LINQ

I have been looking at the examples for updating models in the MVC architecture. There are plenty updating the model where the linq (SQL or EF) is in the controller. And there are others where the service layer is used to fetch values. The only example I can find its going to be awkward to use with an IoC container. What I'm looking to ...

How to avoid having to place <%@ Import Namespace="MyProject.Helpers" %> on top of every view?

Hi, I'm working on my first asp.net mvc application and I'm using custom helpers like the Html.Label() from the example on the official site. For having access to Html.Label, I have to place <%@ Import Namespace="BRG.Helpers" %> at the top of every view. Is there a way to avoid having to do that? I've read somewhere someone ment...

IIS 7 AND HTTP Error 503. The service is unavailable

I am going gahgah here! I'm hosting an ASP.Net MVC app over at discountASP then I got a very well desired traffic spike yesterday and the server starts to buck and sending out http 503: Service unavailable intermittently. Please does anyone know what I need to do to make things better? The folks at DASP say they have 'doubled my connect...

Custom html helpers: Create helper with "using" statement support

Hello guys, I'm writing my first asp.net mvc application and I have a question about custom Html helpers: For making a form, you can use: <% using (Html.BeginForm()) {%> *stuff here* <% } %> I would like to do something similiar with a custom html helper. In other words, I want to change: Html.BeginTr(); ...