asp.net-mvc

CustomModelBinder namespace/project location

For larger apps, where do you guys typically place your CustomModelBinders? Are they grouped with your controllers, your view, standalone in a seperate library? Just curious since ours does much of the heavy lifting (knows about form collections and calls repository models). ...

IIS7 & Castle.Microkernal.Lifestyle.PerWebRequestLifestyleModule regestering problems

I'm trying to deploy an ASP.NET MVC app to iis7 and am getting the error: Looks like you forgot to register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule Add '<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.MicroKernel" />' to the <httpModules> section o...

ASP.NET MVC - How to show unauthorized error on login page?

In my ASP.NET MVC app, I have most controllers decorated with [Authorize(Roles="SomeGroup")] When a user is not authorized to access something, they are sent to "~/Login" which is the Login action on my Account controller. How can I determine that a user has reached the login page because of not being authorized so that I can show a...

What is the best way to generate a PDF and Excel file from ASP.Net MVC

I need to generate a PDF and an Excel file from my ASP.net MVC application. Any ideas on the best way to implement this? ...

ASP.NET MVC - Linq to Entities model as the ViewModel - is this good practice?

Hi There, Quick questions really. I am currently building a site using asp.net MVC and the entity framework. I have a couple of repositories in place which return entities or lists of entities. I am finding that in the majority of my pages I'm having to pull data from a variety of related tables. This is ok so long as I load up the rela...

How do I send data from DropDownList to Html.BeginForm in MVC?

I would like to pass a date from a drop down list to my ID in the Html.BeginForm. This is what I have so far. <%using (Html.BeginForm("Inquiry", "Billing", new { Date = ????? }, FormMethod.Post)) <select id="myList" name="myList" > <option>Term - Balance</option> foreach (var item in Model.Term) { ...

Are ASP.NET MVC routes cached?

I added a route to my asp.net mvc application to handle some json requests I need to do. This works great on my development pc, however when I installed in QA, the route isn't working at all. I tried to physically type in the address and get a "Bad Request". Can anyone assist with this? I have restarted IIS to try to clear any cache ...

ASP.NET MVC - Updating Multiple Partials/View

How do you guys update (let's say) two partials in a controller action going to the View? For example, you have a left nav partial for links and on the right is your main content. Your main content has a ViewModel that it binds to. Do you guys have a seperate ViewModel for your nav page? If so, do you then create a bigger ViewModel e...

asp.net mvc List of Selectlists

I am trying to add some filter logic to a document database. The list of select lists varies by which product and category a user has selected. /productx/marketing would have selectlista, selectlistb, and selectlistc while producty/marketing would have selectlista, selectlistd, and selectliste I am struggling to visualize how i can a...

ASP.NET & MVC Hybrid app model not working

I have a web application containing both asp.net web forms and mvc views but run into issues with strongly typed models in the view. This is the page directive from the view: <%@ Page Inherits="System.Web.Mvc.ViewPage<Survey.Models.SurveyResponse>" Language="C#" MasterPageFile="~/Views/Shared/ExternalSurvey.Master" %> but within th...

When to use TempData vs Session in ASP.Net MVC

I am trying to get the hang of MVC framework so bear with me. Right now, the only thing I'm using the session store for is storing the current logged in user. My website is simple. For this example, consider three domain objects, Person, Meeting, and File. Users can log in and view a "members only" profile of a meeting and can add file...

Possible to create an attribute that gets evaluated after instead of before?

I'm aware of writing custom attributes that decorate a method and get evaluated before the method executes, but is there a way to modify it so the attribute gets evaluated after the method gets executed? Theoretically (in pseudo-code): public void MyMethod() { Console.WriteLine("Hello World"); } [AttributeToExecuteAfter] Am I mi...

How to Implement a Custom RoleProvider?

Hi Guys I'm trying to implement a custom RoleProvider in my ASP.NET MVC application. I've created a custom MembershipProvider and it works, in that I'm able to successfully validate the user. The next step is to implement the RoleProvider to restrict access to certian Controllers to Admin users only. Can anyone provide me with a quic...

$.getJSON for asp.net mvc

I am trying to create dropdown list when selecting item from the other dropdown list. I use $.getJSON to get data from my action in controller here is my code. JQuery Code looks like this. $(function() { $("#GroupName").change(function() { //alert("Test"); var str = ""; $("select option:selecte...

Loading a Silverlight library in an ASP.NET MVC Web Application for reflection?

Hey, This is a pretty specific question, but I need to load a Silverlight application library into my ASP.NET MVC Web Application to reflect over the types and build a list for the user to select from. The purpose of the application is to let users upload their custom-built libraries and test it in a "sandboxed" environment. Anyway, af...

How to test Repository Pattern with ADO.NET Entity Framework?

While using Repository pattern I find it difficult to understand the reason of designing the software with TDD technique while in reality you will have to implement the Interface for your repository in your persistence dataset. To make my point clear I will submit an example: I have the following Interface on my domain model: public i...

How to add help prompt attributes to Business Objects in MVC and display in View

How can I provide some form of Attribute against my Business Objects in my ASP.Net MVC application so that I can pick up the help texts in the View and have them appear as pop-up hover help texts like this: <%= Html.TextBox("PostalCode", Model.PostalCode, new { title = "Please enter your postal code." })%> I want to be able to g...

Domain Driven Design: When to make an Aggregate Root?

I'm attempting to implement DDD for the first time with a ASP.NET MVC project and I'm struggling with a few things. I have 2 related entities, a Company and a Supplier. My initial thought was that Company was an aggregate root and that Supplier was a value object for Company. So I have a Repository for company and none for Supplier. Bu...

How to detect if a visitor is human and not a spider

I am logging every visit to my website and determining if the visitor is human is important. I have searched the web and found many interesting ideas on how to detect if the visitor is human. if the visitor is logged in and passed captcha detecting mouse events Detecting if the user has a browser [user agent] detecting mouse clicks [...

Can Bots/Spiders utilize Cookies?

I am trying to detect is a visitor is human or not. I just got an idea but not sure if this will work or not. But if I can store a cookie on the persons browser and retrieve it when they are browsing my site. If I successfully retrieve the cookie can this be a good technique to detect bots and spiders? ...