asp.net-mvc-2

Grouping roles in custom membership provider in ASP.Net MVC 2

Maybe I'm using the wrong terms, but I've been Googling for two days and just can't find anything on this: grouping roles/permissions. Or maybe I don't quite understand membership in the ASP.Net model. Currently I have a homegrown authentication system in a PHP site, with users, permissions, and roles. Each role (such as "User" or "Te...

ASP.NET MVC OnActionExecuted ActionFilter

I trying to check if an exception has been raised by an action with the filterContext.Exception below: public class Test : ActionFilterAttribute [...] public override void OnActionExecuted(ActionExecutedContext filterContext) { if (filterContext.Exception != null) { ...

MVC2 Routing with WCF ServiceRoute: Html.ActionLink rendering incorrect links!

I have a WCF service that lives side-by-side with an MVC2 web site. I'd like for my URL for the service to look like this: http://localhost/projdir/Service The MVC site is in its infancy so it still has all its boilerplate controllers etc. The following code works at first glance in global.asax: public static void RegisterRoutes(Ro...

Post with jQuery not working in Asp.Net MVC?

I'm trying to make a post call to an action method in MVC 2. But it doesn't seem to work. I have set a break point right at the beginning of the action method, but the debugger never hits the breakpoint. What am I doing wrong? Here's the jQuery (for simplicity I have simplified it by removing parameters both from the call and the action ...

ASP.NET MVC2 Routing / Folder structure

In ASP.NET MVC2, How do I change routing/folder structure so I can have Views\FOLDER\Account\ChangePass.aspx Rather than: Views\Account\ChangePass.aspx I don't actually want to do it for the account, but I'd like to structure things like that, e.g. SO I can have two different views like: Views\Categories\ Views\Admin\Categori...

How can i automatically update a field before saveOrUpdate with Sharp Architecture

Lets say i have this entity public class Address : Entity { public Address() { ModifiedDate = DateTime.Now; } [NotNull] public virtual Province Province { get; set; } [NotNullNotEmpty] [Length(Max = 80)] public virtual string Line1 { get; set; } [Length(Max = 80)] public virtual string ...

ASP MVC 2 + Razor - Child actions are not allowed to perform redirect actions.

Hello, In _Layout.cshtml file I have following entry: @Html.Action("LoadPagesStructure", "Page") Inside PageController class, LoadPagesStructure methos looks following: [ChildActionOnly] public ActionResult LoadPagesStructure() { ViewModel.Pages = new List<string>() {"page1", "page2", "page3"}; return View(); } Fi...

ASP.NET MVC2 View Model for multiple view forms and data

Hi, one thing that has been puzzling me since learning MVC2 is the following case scenario: I have a view which contains two latest news lists, a login form and a signup form. Every example I found on Views and View Models so far has a one-to-one example such as a simple login form etc. But how do I create a model that provides the pr...

disable button when first click in jquery

I want to disable button when user first click it so it must not save multiple record if a user have a slow connection. Im using asp.net mvc2 ...

Why does a lamba-expression work, but when accesing the Model object directly it doesn't?

Here's the error I get: Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0411: The type arguments for method 'System.Web.Mvc.Html.SelectExtensi...

Why won't my Model accept what I'm selecting from the DropDownList?

I edit the Dinner (from the NerdDinner tutorial) and save it, but the Country isn't persisted. Here's my code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace NerdDinner.Models { public class DinnerFormViewModel { private static string[] _countries = n...

ScaffoldColumn attribute on type object

It seems that to skip a member to come on a View you can set ScaffoldColumn attribute to false in your model [ScaffoldColumn(false)] public object Id { get; set; } but here i see that Id is of object type. Is this the only way? I tried with [ScaffoldColumn(false)] public int Id { get; set; } but it didn't work. How can i prevent...

ASP.NET MVC 2: "The process cannot access the file <filename> because it is being used by another process."

I'm trying to use Controller.File to return a FilePathResult from a view in my ASP.NET MVC 2 project. I use it like this: return File(pdfFilePath, "application/pdf", "foo.pdf"); However I keep getting this error in the yellow screen of death: The process cannot access the file [the file path] because it is being used by another proce...

MapRoute (Asp.Net MVC 2.0 .NET 4.0)

Hi, is there any possibility to create a maproute which would use always one method and it won't be necessary to put it in address? I mean I've got controller with one method (Index) and it displays items depend on methods argument. public ActionResult Index(string TabName) { var tab = (from t in BlogDB.Tabs ...

MVC2: Ajax call runs always in error function. Why? Whats wrong?

aspx site: <script type="text/javascript"> function AjaxTest() { var codeVal = "hello world"; if (codeVal) { $.ajax({ type: "POST", url: "CheckAge", data: { code: codeVal }, contentType: "application/json; charset=utf-8", dataType: "json", async:...

Trying to position my image a little bit lower, but it drags everything down with it.

I'm trying to position my picture a little bit lower so the center of the image aligns with the vertical center of the header tag. Here is the both the HTML and the CSS. Thanks for the help! #articlesummary { border: 2px solid red; width: 750px; } #articlesummary h3 { border: 2px solid red; display:inline; co...

Default value for parameter in Controller Method is overriding everything

Hello i have just started learning mvc2 and im having a problem with the default value for the parameter page(you can see the method below). Its always 0 regardless of what i type in the URL. For example this h.ttp://localhost:52634/Products/List/2 should show page 2 but when in debug mode the page parameter is 0, so im always gettin...

ASP.NET MVC 2 controller not cached

Hi All, I have amaster page that calls render action: <% Html.RenderAction("CategoryList", "Category", new { selectedCategoryId = Model.selectedCategoryId }); %> and the action looks like: [ChildActionOnly] [OutputCache(Duration = 10, VaryByParam = "none")] public ActionResult CategoryList(int? selectedCategoryId) { CategoryLi...

When to commit NHibernate transactions in ASP.NET MVC 2 application?

First, some background: I'm new to ASP.NET MVC 2 and NHibernate. I'm starting my first application and I want to use NHibernate, because I come from JSP + Struts 1 + Hibernate web applications. No one seems to be talking about this, so I guess it must be pretty obvious. Still I scratch my head because I can't find a solution that accomp...

LINQ no longer has intellisense in views

Ever since we upgraded to .Net 4.0 and VS2010 (from 3.5 and 2008) we can no longer get intellisense on LINQ to kick in when working in our views. Before the upgrade everything was working fine, but after the upgrade it's actually listed as an error when we try to use things like .Where() on a collection. Oddly it will compile fine and ru...