asp.net-mvc

Accessing static content of an ASP.Net MVC project with IIS7

I've create a web site on my local IIS 7 with my own ASP.Net MVC project on its root. Everything is working fine except for the static content. Going to http://localhost:8080/Content/Site.css gives me a 404. I can see the folder on IIS Manager. The content is served fine with the small development server you get when you run the appl...

ASP.Net MVC Exception Logging combined with Error Handling

Hi. I am looking for a simple solution to do Exception Logging combined with Error Handling in my ASP.Net MVC 1.0 application. I've read lots of articles, including Questions posted here on StackOverflow, which all provide varying solutions for different situations. I am still unable to come up with a solution that suits my needs. Here...

Best Solution for Caching....

Hi there, Where is the best place to implement caching in a web based app? At the presentation layer (hope not)? At the Business Logic Layer? At the data layer? I'm going to use something like memcached or MS Velocity under the hood. I'm just finding myself writing so much code to update the cache here and there in the business lo...

Change Visual Studio Default Browser in an ASP.NET MVC project

FireFox is set to my Windows default browser. I want to change the default browser used by Visual Studio for debugging. Normally the route I'd take to do this is right clicking on an .aspx file and setting the default from the Browse With... dialog. Unfortunately, ASP.NET MVC Views don't have the Browse With... option. What other ...

Uploading different filetypes for different model properties

I have a model with ImagePath and PDFPath properties. When they click save, that calls the POST action method in the controller. I need to check that they have only uploaded image files and pdf files. If they have uploaded something other than these filetypes I want to set a ModelState error with the following: ModelState.AddModelErro...

Passing data from Controller to a View and back to a Controller

I'm trying to do an invitation system, and if my solution is looking weird even to myself something gotta be wrong. A user call an URL for an invitation site.com/Account/Invitation/invitationGUID public ActionResult Invitation(Guid invitationGUID) { //Check for the existence of the invitation id if(true) return R...

Render a View dynamically with UI-related attributes defined in the business entity

I'm using System.ComponentModel.DataAnnotations to give codesmith (using reflection to parse the field-attributes on BE) UI-hints to build my views. But I find DataAnnotations is limited enough. I like something richest, building new custom attributes where one could have more settings to build also complex user interface. I'm too lazy t...

Where should I send the confirmation email from?

I am integrating a mailing list into an existing CMS in asp.net MVC. I need to send a confirmation email to the subscriber. Where should I send it from, the controller, Or the service layer? Clarification: I would definitely create a separate service method called SendConfirmationEmail(). The question is who calls it the controller han...

ASP.NET MVC Partial View with Form

I have a scenario I want to use a partial view but I'm having issues with it passing data to the controller. Here is a basic example of what I'm trying to do. Objects: Customer Order A Customer has an IList<Order> on it. I want the partial view to allow the user to edit the information. I can get the data to display but when the ...

View Engine for ASP.net MVC

what are the things to consider before choosing a View Engine for ASP.net MVC ...

How are foreign keys and Guids dealt with in LINQ to Entities?

Hi, Just using this as an example... Here are the columns in my UserProfile table: ProfileID (Primary key) UserID (Foreign key) Address PhoneNumber now, when I want to add a new user to the database using LINQ to Entities, here is what I'm doing: UserProfile profileToAdd; profileToAdd.ProfileID = 0; profileToAdd.Address =...

What's the equivalence of an SQL WHERE in Lambda expressions?

Hi, Here's what I have: decimal sum = _myDB.Products.Sum(p => p.Price).GetValueOrDefault(); I also have two dates: DateTime start, DateTime end I want to retrieve the sum of all of the product prices between start and end, but I can't figure out how to incorporate the variables into the lambda equation. How do you incorporate variab...

Which MSDN Library Shipment includes Asp.net MVC help reference?

I'm an MSDN subscriber (Premium license with VS Pro) but I didn't get any MSDN Library DVD updates for quite a while now. What I miss most is Asp.net MVC help reference. I know I can use web to get info, but that's not an option since I may not be always connected and I'm also used to local library resources. Anybody knows where to get ...

ASP.Net MVC: File Structure, Controllers, and Views: How do I separate admin from rest?

Basically how can I get this: sitename/Admin/Forum/Index versus sitename/Forum/Index Background: To learn MVC I've taken on creating a cheesy forum application. Before knowing anything about MVC I just jumped right in with the default director structure, basically this: Now all these controllers/views deal with admin side things. ...

Need help with LINQ query and ASP.NET MVC?

My repository returns a list of Accounts. Each account has a date and a MoneySpent decimal amount. So, I have my list of Accounts and in my controller I'm trying to process this list a little. I want to have an object which contains the string name of all the months in my Account list and a Sum of all money spent for that month. Here...

What would LINQ to Entities return when selecting an integer id for a given row name if the record does not exist?

Here's the code: string name = "myName"; int id = (int)_myDB.ThingTable.Where(thing => thing.ThingName == name) .Select(thing => thing.ThingId); I have an error saying System.Linq.IQueryable cannot be converted to int (I'm assuming it's so that I don't end up with a case where no rows are found- no id is returned...

Best Practice - Share UnityContainer across Tiers in Asp.net MVC?

I have a UnityContainer that gets it's configuration information at runtime in the global.asax file of an MVC web app. I also have services in another assembly that need access to this container so that they can perform resolutions manually. How can I best share the two? I don't want to have a reference between my Data assembly and MV...

What's the best way to test against my MVC repostiory?

Hi, I've built a repository and I want to run a bunch of tests on it to see what the functions return. I'm using Visual Studio 2008 and I was wondering if there's any sandbox I can play around in (Whether in visual studio 2008 or not) or if I actually have to build a mock controller and view to test the repository? Thanks, Matt ...

Can IIS7 re-compile an ASP.Net MVC project?

I'm publishing an ASP.Net MVC as an IIS7 site on my local workstation. Is it possible to get IIS7 to re-compile the project when needed? ...

MVC/Unity - How to inject dependencies into custom FilterAttributes?

I Have a custom HandleErrorAttribute that extends FilterAttribute. How can I have Unity inject dependencies into this attribute at the same time that it injects the controller's dependencies itself? ...