asp.net-mvc

Best way to model page attribute data onto different database tables

I'm developing a website (using asp.net-mvc) with a SqlServer 2005 database. I have numerous database tables which drive content pages for the site e.g. I have a table called Activity: Activity ----------- ID Name So for each activity record, there would be a corresponding 'Activity' page. The same applies for other tables e.g. Locati...

How can I authenticate the user within Json controller action?

I have a .NET MVC controller action that returns a JsonResult to a YUI AsyncRequest callback. All is working fine with the AsyncRequest call and the "Content" model data is successfully updated. How can I now assure that the user is logged before the AsyncRequest is made? Normally I would use the [Authorize] attribute which returns an e...

Which Java based MVC framework is most similar to ASP.NET MVC?

I have been learning ASP.NET MVC in the last few months and I think it is a great improvement over ASP.NET. For me personally, it is a joy to use (as opposed to ASP.NET WebForms :)) I started wondering how the .NET world managed to live so long without any such framework (at least not wide spread and supported by Microsoft as there may b...

ASP.NET MVC: Controlling naming conventions of controllers / views?

Hi there, Can anyone tell me how i can manually edit my naming convention of my routes.. Let me explain. I am programming everything in english as per microsoft standards but i require www.mydomain.com/Reserva (Spanish for reservation) I actually have the following ReservationController and then below views i have a folder called...

Url Encoding in MVC

I am confused about what is supposed to be encoded and when and when it gets decoded. For example: <%=Html.ActionLink("Login","Login", new {controller="Account", returnUrl=HttpContext.Current.Request.RawUrl})%> on the login page the address will be as follows: /Account/Login?returnUrl=%2FPreviousDir...

ASP.NET MVC JSON Post a HTML Form to a View?

I have the following code: jQuery: $.ajax({ url: '/personcontroller/getperson', cache: false, type: "POST", data: $('#person').serialize(), success: function(data) { alert('yay'); } }); }); Controller: public ActionResult getPerson(Person person) { return new Json(person); } Html Form/Spark: <form id="person"> <i...

Why do Validation Errors persist?

A user submits registration information to the form: <h2>Create</h2> <%= Html.ValidationSummary("Create was unsuccessful. Please correct the errors and try again.") %> <% using (Html.BeginForm()) {%> <fieldset> <legend>Fields</legend> <p> <label for="Nbk">Nbk:</label> <%= Html.TextBox("Nbk"...

Code behind user control

How would one go about performing controller actions from withing an ASP.net MVC user control? My scenario is that I have a userID and I want to transform it into a name from the database. To do this I've annotated my model with a display type and put a User template in the shared display templates but I'm not sure where I should wri...

Prefix in xVal client side causing ModelBinder problems

Over the last 24 hours, I've become greatly enamored of xVal. I introduced it into my personal web site, and it works like a champ--I can't believe how easy it was to get it going. I'm using ASP.Net MVC, xVal 1.0, and the DataAnnotations validators. Now trying to put this same code into a work application, I'm seeing different behavio...

Nhibernate Session and ASP.NET

Using NhibernateProfiler we have determined that we are creating an ISession for every http request. However the ISessions never close. We can see in the log where localSession.Close() fires. Is there something in our config file that would cause the session to never close? Are there any other reasons localSession.Close(...

Generate XML sitemap automatically using routers and controllers in ASP.NET MVC

Hi,would it be possible to generate a XML sitemap for search engines automatically by iterating the routes and the controllers' action of an applicacion? if you could provide me with an idea or so I would appreciate it. Thanks. ...

ASP.Net MVC - Passing posted value to view

I am creating a search page, the user types in the textbox and click 'Search', the controller takes the FormCollection in its Action method. I do the search and return the results to the view however I want to return what the user searched for to the view. Is the TempData the best place for this or is this a risk? ...

What will passing a Dictionary into Controller.Json return?

Let's say I have a Dictionary<string,object> like so: var foo = new Dictionary<string, object>(); foo["bar"] = new { Quux = "bacon", Quinge = 42 }; foo["baz"] = DateTime.Now; I expect it the result to the user would be akin to: {"bar":{"Quux":"bacon","Quinge":42},"baz":"2009-12-02 17:23:00"} However, it could just as easily...

MVC 2 Beta 2 - TempData Bug?

ASP.Net MVC 2 Beta - I am aware there are some changes to TempData in MVC 2 Beta. When trying to use TempData if the key name get/set have different case sensitivity, then the key doesn't seem to get destroyed. e.g. in Controller TempData["Message"] = message; in View <% = TempData["message"]%> My view will is play the value ...

DateTime binding default error message using Linq to SQL

Hi, i'm using Linq to SQL for my model with a custom validation layer. I cannot find the way to edit or change the default message: The value '29/34/1980' is not valid for BirthDate. BirthDate is of course my textbox. Any ideas? Thanks EDIT: this is the simple code i'm using: <%= Html.Label("Data di Nascita (GG/MM/AAAA)", "BirthD...

Model binding and display trimmed string property

My strongly typed View inherits from a "Person" object that is created with Linq to SQL. In my "Edit" View, i have to display of course old values: <%= Html.TextBox("FirstName") %> "FirstName" is NCHAR, so it need to be trimmed. So i ended up with: <%= Html.TextBox("FirstName", Model.FirstName.Trim()) %> and this works. But when fo...

Sort Date Column in jqgrid

I am using ASP.NET MVC with JQGrid. The issue now is, how can I sort the date column in the JQGrid? Any ideas? ...

How can I make a query string tamper-proof?

I need to use query strings in a URL, but need to ensure that they haven't been tampered with. I found a solution which almost works, but the encoded strings get mangled by a service my app needs to use. Can anyone think of a different solution? EDIT: The solution I mention doesn't work for me because the Base64 encoded query string i...

Controller Test problems

Hi. I want to test a mvc controller. I'm using Moq to mock the services, but I don't know how to mock this.Request.Files["Attachement1"] and this.Server.MapPath("~/Temp") ("this" is the controller) I tried to create a new Mock<HttpRequestBase>(); but this.Request doesn't have a setter. Help me please with an advise. Thanks ...

Properties that Are Alive on A Single Page Request

I have an ASP.NET MVC page, and inside the page I will make a few AJAX call. What is the property inside the Controller whose values are persisted as long as the page is still there ( even during AJAX call), and are destroyed when I switch to other page request? Controller.Session's keys and values, as we all know it, are alive and acc...