asp.net-mvc-2

Framework for an MVC .NET app that also has a thin client component?

If I plan to create a system that is pretty much an MVC .NET site, with the typical separation of components (data, core, ect) but also would like to have a thin Windows client that can access some of those same components remotely, which framework would I want to look at using? ...

Storing ASP.NET MVC 2 session data on login

I've got an implementation similar to this: http://stackoverflow.com/questions/1710875/better-way-of-doing-strongly-typed-asp-net-mvc-sessions for quick access to frequently-needed user data... but i have two questions: 1) will there ever be a time when a user is logged in, but the session would be invalid or reset? I always thought th...

ReSharper 5.0 choking on strong-typed view model that's located in same project

I'm using VS2010, ASP.NET MVC 2, and ReSharper 5.0. When I create a new view that's typed off of a model from the same project as my view, ReSharper doesn't see the reference to the model. This is the definition of my view: <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Web.Domain.UserViewModel>" %> Domain.UserViewModel ...

Service is not calling from controller - MVC

Hi Solution is deployed on server with precomplied option. in local pages are saving but in deployed url error is thrworing. I am calling controller from web page and controller will call wcf service. Error details- System Error. Description: An unhandled exception occurred during the execution of the current web request. Please rev...

In Asp.net 2.0 how to retain data in the controls in view while redisplaying same view with the validation error message

Hi, I want to retain data in the view controls like drop down list, radio button, checkbox, textbox while displaying same view again with validation fail message. Data is in the drop down list bind using the ViewData. Check box data bind using viewdata. User enter values in the textbox and for checkbox control. When view is displayed w...

ASP.MVC :Web.Config and Authorize attribute

I have an AdminController protected by an Authorize attribute like this [Authorize(Roles = "Admin")] public class AdminController : BaseController { ..... } And I have in my web.config this security location section <location path="admin"> <system.webServer> <security> <authorization> <remove users="*...

Global action filter in ASP.NET MVC

Dear Experts, Is it possible to create a global action filter that will automatically apply to all actions in all controllers in ASP.NET MVC application? I want something like "before_filter" defined in ApplicationController in Ruby on Rails. Thank you for your help. ...

Custom user in ASP.NET MVC 2

Hi, I'm trying to implement a custom user object in ASP.NET MVC 2. I've seen a solution where you can do some magic in Global.asax to turn Controller.User into another type, say CustomUser. But Controller.User is still an IPrincipal, which means I have to cast it to CustomUser every time I want to use it, and I don't like that at all. ...

ASP.NET MVC 2 Validate Nested Objects

According to the spec, complex child properties (aka "nested objects") are validated only if an input is found for one of the nested object's properties. For example, if Person has properties { string Name, Address HomeAddress } and Address has properties { Street, City }, and an action accepts parameter of type Person, then Person.Home...

Extra If Statements Or Repetative Code in C#

Trying to figure out which makes more sense <%foreach (var item in Model.items) { %> <tr> <td> <% if (!item.isMgmt) { %> <a href="/MVC/AzureMail/Unfiled/<%:item.uName %>"> <%:item.uName%></a> <% } else { %> <%:item.uName %> <% } %> </td> </...

How can I get a radiobutton to be pre-selected in ASP.NET MVC 2?

Hello, Let's say I've this public class OrganisationData { public NavigationData navigationData {get; set; } } Then public class NavigationData { public string choice {get;set;} //other properties omitted } I've this on my view <% Using(Html.BeginForm()){%> <p> <% = Html.RadioButtonFor(x => x.organizationData.navig...

How to register scripts and stylesheets at Controller level

Hi. I want to be able to register scripts and stylesheets. These items would then be added to the head section of the current page. For example, I have a partial view called ImageViewer that renders a few images and relies on a script. Instead of adding this script in the view using the ImageViewer, I'd like to be able to register this s...

ASP.NET MVC2 and routing

I have the following route: routes.MapRoute( "edit_product", // Route name "Product/Edit/{productId}", // URL with parameters new { controller = "Product", action = "Edit", productId = UrlParameter.Optional } // Parameter defaults ); Why does this code works...

Returning JSON data to view page in ASP.NET MVC

I'm working on MVC project and i using jQuery in view page to get data from controller. public JsonResult CheckUpdate() { dt = dt.AddSeconds(-100); IQueryable<Tweet> _tweet = ttr.CheckTime(dt); return Json(_tweet, JsonRequestBehavior.AllowGet); } This is a method in my controller which gets data back from the repository class ...

ASP.net MVC 2 - Adding routes to external controllers

Is it possible to add routes to controllers defined in external assemblies? Everything I've seen so far doesn't seem to allow for it. Based on the below help I've added the following two routes as a test and no matter what I do it keeps defaulting to the "Default" route...however if I change the name of the "Browse" controller to the n...

mvc2, query and qtip issue

Hello, I'm having an issue where in my controller, I'm setting values in a collection and storing them in ViewData. eg: ViewData["ex1"] = new SelectList(ex1); // a simple collection ViewData["ex2"] = new SelectList(group.Members, "Id", "Gender"); I'm passing these to my View and looping through like this. eg: <div id="divListBox" s...

Asp.Net MVC 2 - Weird behavior: RedirectToAction and ValidationSummary not working

I've been working with MVC 2 for awhile and ive done ReturnToAction as well as ValidationSummary - but this is a little different in that my "submit" buttons are controls by javascript/JQuery - i debug the action and it does go into the correct Controller Action but once it passes over RedirecToAction, nothing happens.... My second prob...

Call action of another controller and return its result to View

I have a scenario where I need the following functionality: In View I have call as: $.ajax({ type: "POST", async: false, dataType: 'json', url: "ControllerA/ActionA", data: { var1: some_value }, success: function (data) { if (data == true) { form.submit(); } else if (data == fa...

Model binding issue in LINQ to SQL

I am just now starting to work with LINQ, and am pretty familiar with MVC. I have a strongly typed view that is updating a record. I have successfully done a creation: This works fine, and creates a record in the database: public ActionResult Create(TABLEMODEL tableModel) { DBDataContext db = new DBDataContext(); if (ModelState...

ASP.NET MVC 2 Membership users table mdf file

I have an MVC 2 project where I have my own *.mdf file in the App_Data directory. The *.mdf file contains my normal tables but not a users table. Is it possible to add a Users table to my *.mdf file and work with that instead of the simple register form? (if so: how could this be done?) Because I don't know how to do these things above...