asp.net-mvc-2

linq query and results display by category

I want to display list of items which belong to certain category like this: Category I Item 1 Item 2 Item 3 Category II Item 6 Item 7 Category III Item 10 Item 11 Item 12 Item 13 What is the best (and easiest) way to do this? I started doing this with two queries - one gets all goals, and then in foreach loop (in controller)...

Display PDF in Html

Hi, i want to show PDF in a view in MVC, following function return file public ActionResult TakeoffPlans(string projID) { Highmark.BLL.Models.Project proj = GetProject(projID); List ff = proj.GetFiles(Project_Thin.Folders.CompletedTakeoff, false); ViewData["HasFile"] = "0"; if (ff ...

Detecting orphaned records with Entity Framework

I'm wondering if there is a better way to clean up orphaned records using ASP.NET and the entity framework. For my example there are three objects: Persons, PhoneNumbers and Emails. PhoneNumbers and Emails can be associated with multiple people (ie [email protected] could go to multiple people). I want to make sure there are no o...

ASP.NET MVC page, CSS (?) problem

I have an ASP.NET MVC site (Master Page + Content pages). On the master page, I have a menu. When some of the options are selected on the menu, it brings you to the appropriate controller and shows the page, which is fine, but it also shows a submenu. The submenu shows just fine, but the issue lies in the menu. I cant get the menu's css ...

Problem applying data annotation in asp.net mvc2

Im facing problem when trying to apply data annotation. In my case im passing FormCollection in controller [HttpPost] public ActionResult Create(string Button, FormCollection collection) { if (ModelState.IsValid) { } else { } } and in ModelState.IsValid condition always have true value. Although i have...

Solution to metadata.HideSurroundingHtml not working

I have written a custom DataAnnotationsModelMetadataProvider that sets HideSurroundingHtml dynamically. public class ContentDrivenModelMetadataProvider : DataAnnotationsModelMetadataProvider { protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, ...

Different ASP.NET 4 page contents depending on build type.

Hi All! While working on ASP.NET MVC 2 web site I faced to the following problem. I need to render speacial script on site's master page for Google analytics when building solution for production, but for debug and test builds this script should not be rendered. I've tried to find a way to make it automatically, but was not succeded in ...

Facebook IFrame Application issues for certain users

We have a strange issue with running an Facebook IFrame application (using MVC 2). When I run my app and log into Facebook, I get to the application just fine. But when my coworker does it, she gets the following error: API Error Code: 100 API Error Description: Invalid parameter Error Message: Requires valid next URL. Typically thi...

What are the best documentation sites specific to ASP.Net MVC2?

Now that the MVC 2 framework has been out for a while, I'm finding it very difficult to find documentation & answers specific to MVC2. What are some good sites specific to MVC2? ...

How to support leagcy urls(Web forms type) in asp.net mvc routing

We have recently shifted to asp.net mvc, but we still need to support some legacy urls. What is the best way to handle this situation. Is it Application_PreRequestHandlerExecute() event in global.asax, that I need to use or is there any better way? ...

Asp.Net MVC 2 - Changing the PropertyValueRequired string.

Using a resx file in the App_GlobalResources directory, I've been able to change the default message for the PropertyValueInvalid string of the model validators. But it doesn't work to translate the message when a value is required (PropertyValueRequired.) In the Global.asax.cs Application_Start() I've changed the resource class key, l...

Query String Routing with Nullable Types

I am having one of those coder's block days. I should know this but instead I'll ask for a little help. I have two routes: /Login /Login?wa=wsignin1.0&wtrealm=http://localhost/MyApp Accessing the Action method for the first with an HTTP GET returns the login page where-as the second does some federated authentication stuff. I defin...

mvc2 host on iis6 : The incoming request does not match any route.

I have to host my project on iis6, I can not change iis setting on server. So, I modified global.asax like below. If I add a default.aspx and browse project I got error like : The incoming request does not match any route. if I dont add default aspx I got HTTP Error 403.14 have any idea? thanks public static void RegisterRoutes(Ro...

Can I register a custom model binder somewhere other than Global.asax?

It would be handy to limit the scope of a custom model binder for just a specific controller action method or its entire controller. Hanselman wrote a sentence that implied alternative locations for custom model binder registration but never seemed to finish the thought: You can either put this Custom Model Binder in charge of all yo...

How to eliminate authentication on my MVC app that is called from asp.net forms app

Curious what recommendations anyone has. I have an existing asp.net forms application that does a Forms Authentication and has identity impersonate turned on. The application has a link to a questionnaire that I would like to develop separately in an asp.net MVC application, but I don't want the users to click on the link and be prompt...

Can you get notes and tasks from Exchange with VB.NET?

I'm currently looking into expanding a project to include the syncing of notes and tasks from a web application with exchange/Outlook. Though at the moment, this is only an idea. Unfortunately for me, it's the first time I've considered doing any form of Exchange integration at all from any application. So I'm wondering, is what I've ...

ASP.NET MVC: How do I validate a model wrapped in a ViewModel?

For the login page of my website I would like to list the latest news for my site and also display a few fields to let the user log in. So I figured I should make a login view model - I call this LoginVM. LoginVM contains a Login model for the login fields and a List<NewsItem> for the news listing. This is the Login model: public clas...

Html.DropDownListFor not behaving as expected ASP.net MVC

Hello, I am new to ASP.net MVC and I am having trouble getting dropdown lists to work correctly. I have a strongly typed view that is attempting to use a Html.DropDownListFor as follows: <%=Html.DropDownListFor(Function(model) model.Arrdep, Model.ArrdepOptions)%> I am populating the list with a property in my model as follows: Publi...

What can be causing Html.ValidateFor() method to produce a compile error?

I have view with the following which works: <%= Html.TextBoxFor(m => m.FirstName, new { @class = "required_field_light" }) %> <%= Html.ValidationMessageFor(m => m.FirstName) %> However, if I change the ValidationMessageFor() to a ValidateFor() like this: <%= Html.ValidateFor(m => m.FirstName) %> I get this compile error: "The best...

Identity.Name is disposed in a IIS7 Asp.NET MVC application Thread

I have made the smallest demo project to illustrate my problem. You can download the sources Here Visual Studio 2008, .NET 3.5, IIS7, Windows 7 Ultimate 32 bits. The IIS Website is configured ONLY for Windows Authentication in an Integreated pipeline app pool (DefaultAppPool). Here's the problem. I have an Asp.NET MVC 2 application. In...