asp.net-mvc

Domain Design class decisions

I am creating a simple web site to get more familiar with MVC 2.0. I've been doing web forms since 1.0 and getting ready to start a major overhaul of a web forms site to MVC. So want to build a smaller app to work out the learning curve. So I'm going to build a time tracking application. I'm using ASP.NET MVC 2.0 and LINQ to SQL. I pl...

asp.net mvc modifying master file from a view

I need to add class attribute to the body tag from a view file (.aspx), but the tag is in the master file. How can I access the body tag from a view? ...

ASP.NET MVC Multi site - where to store site configuration data

I'm developing an ASP.NET MVC multi site application (can host multiple sites from the same application instance / multi-tenant application). I've previously done this in a web forms application and loaded up the appropriate site configuration data (by inspecting the url) on the page_load event of a custom base page. With ASP.NET MVC w...

Is it possible to make data from an Action Method available in an Action Filter?

The Background: We are supplied with html files - 'wrappers' - from our client, into which we need to inject the content that we produce. They have different wrappers for different pages and we have to inject the corresponding content into a special tag that they supply in the wrapper. The wrapper file name corresponds to the name of t...

MVC: Displaying an Image in a form with other form data from database

The question as to how to display an image, stored as an image in the database and as a byte array in code, has been answered several times (e.g., http://stackoverflow.com/questions/880515/display-image-from-database-in-asp-mvc), but what if you want to display the image in the context of a form. That is, I have an object that has sever...

Where / How to fit Solr into ASP.net MVC app (using nHibernate / Repository Pattern)

I'm currently in the middle of a reasonably large question / answer based application (kind of like stackoverflow / answerbag.com) We're using SQL (Azure) and nHibernate for data access and MVC for the UI app. So far, the schema is roughly along the lines of the stackoverflow db in the sense that we have a single Post table (contains bo...

OData WCF Data Services - Related data (by foreign key) doesn't show up when calling the service

When I get the data using the URL in browser, I'm able to see the related data, for example: http://localhost/services.svc/Dinners(1)/RSVPs That lists 5 RSVPs for DinnerId = 1 in my case, but when I'm consuming the OData from a different project, I can only retrieve Dinners, debugging the app shows that RSVPs = 0, while it should be 5....

Action renders View of the first called Action (when an Action calls another Action)

The name is pretty confusing probably. I have a requirement where a URL must be name friendly to represent dates (schedule/today, schedule/tomorrow etc). I don't want to clutter my route mappings with DateTime.Now, DateTime.Now.AddDays(1) etc for different parameters so I decided to create routes that map to an action of the same name: ...

MVC ASP.Net making htmlhelpers from within controllers

If I don't know what htmlhelper I want to use during design time.., Then is it appropiate to try to new up an htmlhelper from within the controller once I understand which model I will be using? So can I make from a controller an htmlhelper and add it to a view later that was not marked up to use the model? Like a data driven applicat...

Can you pass an array from javascript to asp.net mvc controller action without using a form?

I know that if I have a form with multiple elements with the same name I can use this to bind to an array, but is there any way to pass an array from a javascript function to an ASP.NET MVC controller action without using a form? ...

Enable client side validation is not working

Actually i am using server side validation and saw article that only adding link to java script file and using <%Html.ClientValidationEnabled = true%> will automatically enable client side validation but first of all i am using Visual Web Developer 2010 Express 4.0.30319 and here it show error that <%Html.ClientValidationEnabled = true...

How to get a relative path in ASP.NET MVC

How do you calculate a relative path in ASP.NET MVC? ...

Catching an error at view level when database goes offline

hello all, I'm almost embarrassed to ask this question, but here goes. Yesterday I was testing an application that's due to go into production in a few weeks time when an unusual error was triggered by one of my collegues. Basically, she pulled the database connection whilst the view was iterating round an IQueryable collection (inside ...

How to load from database once, and then use static methods to retrive data?

Hey, I'm a first time write long time reader of this site. I'm building an .NET MVC site, using ProfilBase to store a custom user object. The profile base is stored on an database on an other server than the webserver. I have an helper class, UserInfoHelper that contains static method to retrive username, email, telephone etc. Right n...

How Do I support JSON with circular references using jQuery and ASP.NET MVC?

In brief, I'm looking for a way move complex object graphs between browser code (jQuery) and server code (ASP.NET MVC). JSON does not support object references, so standard serialization of a circular referencing object is not possible out-of-the-box. A proposed standard for JSON object references is floating about, which is currently ...

ASP.NET MVC using nHibernate

I looking for some information on how to build an ASP.NET MVC application using nHibernate and n-tier layers. Can I have example please. ...

Checkboxes not working with MVC 2 editor templates and IE8

Iv created an editor template for the boolean type. And it works fine in all modern browsers expect IE8 where any value changes seem to be lost when they are posted to the server. I have read there are 'issues' with MVC checkboxs retaining their values, and as a result the Html.CheckBox helper includes a hidden field on the page to sto...

Jquery extensions for asp.net mvc

Are there any jquery extensions available for asp.net mvc? I'm looking for adapters which can be used instead of having to write all javascripts manually. for instance: just include jqgrid script in the master page, call CreateGrid extension metod to define the grid and return a JqGridActionResult from an action to populate it. I found ...

MVC2 model validation mutually exclusive required annotation

Does anybody know of a good algorithm to mutually exclusively check two properties using a ModelValidator? Something like: [EitherPropertyRequired("BuildingNumber","BuildingName"] public class Address{ public int BuildingNumber { get; set; } public string BuildingName { get; set; } } ...

OpenId/Custom Hybrid Authentication - Bad UX?

Hi Guys, I'm designing a new web application. Some quick points on it: ASP.NET MVC Web Application SQL Server 2008 Entity Framework ORM 3 User Roles: Anonymous, Registered, Administrators. Anonymous users can view stuff, Registered Users can post stuff, Admins can do anything Heavy social integration with Facebook, Twitter and the lik...