asp.net-mvc

Fluent NHibernate get Id of saved object

I'm using Fluent NHibernate in an Asp.net MVC application. I have it set up to start a session and transaction on every request, and commit the transaction at the request end. However, what I want to do is save an object (in this case, a new "Company") and then redirect to that new Company's detail page. How do I get the Id of the new co...

How to send jquery list to mvc controller

I`m completely new to MVC. I have to do the following: I have 4 lists a, b, c, d that are filled dynamically, based on add or delete button clicked. I need to send the values of the list to the controller when submit button is clicked. How can I do that? Please give me an example ot a link where I will have an example. ...

Needs a cause for a error in MVC

What can be the general reason behind the error below: Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper'. ...

Url.Action based on the current route

I'd like to generate a new URL based on the existing route, but will add a new parameter 'page' Here are a few examples: old: ~/localhost/something?what=2 new: ~/localhost/something?what=2&page=5 old: ~/localhost/Shoes new: ~/localhost/Shoes/5 I can not just append &page=5 to existing url because routes may be different. Some use...

Checkbox string[] to int[]

Hello I have a asp.net mvc page with an array of checkboxes that gets posted to an insert-method. And I have this string[] UsergroupIDs, that gets mapped properly, but it contatins "false"-values, and is in string[]. Is there some easy way of cast it to int[] and remove the "false"-values? Using the .Select and .Where if possible? :)...

Pros and cons of having static repositories in ASP.NET MVC application

Hello everybody, What are the pros and cons of using static repositories in an ASP.NET MVC application? Wouldn't it be better to have all the methods available all the time -> means that the class get's instantiated only once instead of having multiple controllers referencing to the same repository class and its methods? Or do I get s...

[asp.net mvc] html.AttributeEncode vs html.Encode

Hi, what is the difference between those two? ...

asp.net: Should dropping dlls into the Bin folder work in asp.net MVC?

I am using Visual Stidio 2010 Beta 2 and just started using MVC, I copied a bunch of dlls into a Bin folder and Included this Bin folder in the project. It seems that there is no reference to these dlls from Controller classes? Is this an MVC thing, or a broken project/VS installation? ...

Asp.Net-MVC: How to style <%=Html.ActionLink()%> with Css?

Hello, Here's a piece of my HTML code <div id = "mydiv"> <% = Html.ActionLink("Some Text","SomeAction")%> </div> I'd like to style it in white so that it doesn't conflict with the background, which is also blue. So I did this: #mydiv {background-color:blue;} #mydiv a:link { color:white} But, it doesn't work -- the color it's ...

Checkbox filter problem when null

Hello I have an array of checkboxes, and trying to filter them, but when no checkbox is checked, it throws an System.ArgumentNullException public ActionResult UserEdit(string[] UsergroupIDs) { IEnumerable<Usergroup> userUsergroups = UsergroupIDs.Where(x => x != "false") .Select(x => (Use...

ASP.NET MVC form won't post

Hi I have a very simple controller and views for displaying and editing user profile data. The problem is that the form will not post. I cannot see the problem... Code as follows: <%= Html.ValidationSummary("Edit was unsuccessful. Please correct the errors and try again.") %> <% using (Html.BeginForm()) {%> <div> <fieldset> ...

How to handle Booleans/CheckBoxes in ASP.NET MVC 2 with DataAnnotations?

I've got a view model like this: public class SignUpViewModel { [Required(ErrorMessage = "Bitte lesen und akzeptieren Sie die AGB.")] [DisplayName("Ich habe die AGB gelesen und akzeptiere diese.")] public bool AgreesWithTerms { get; set; } } The view markup code: <%= Html.CheckBoxFor(m => m.AgreesWithTerms) %> <%= Html.La...

Using IIS Application Request Routing (ARR) for ASP.NET MVC

I use a simple ASP.NET MVC web (the template you use when you create a new site) and the web works as expected in my live environment. I now try to use IIS Application Request Routing version 2. I have a rule that send all reuqests to a different server that match a rule. The settings are a bit like this: http://blogs.iis.net/wonyoo/ar...

ASP.net MVC RC2 Architecture?

I am attempting to find the best way to architect my MVC application. Think of a school with users, but in my case users can be associated with many schools. I am using Entity Framework with a sql backend. I have thus far created Schools, Addresses, Classes, AddressResourceMappings, and (Asp.Net)User Membership. AddressResourceMapping...

What is the difference between BindProperty and SetProperty on IModelBinder

I'm creating a custom model binder in an Mvc application and I want to parse a string to an enumeration value and assign it to the model property. I have got it working overriding the BindProperty method, but I also noticed that there is a SetProperty method. protected override void BindProperty(ControllerContext controllerContext,...

Using Moq to test methods that accept non-primative arguments

Hi I'm trying to write a test for an ASP.Net MVC controller action. I'd like to test that the action invokes a particular method on an injected service, so I'm mocking the service and using .Verify. So in the simple case, I have the following action in my controller: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(st...

mvc with forms auth how do i make a page require authencation

hi, i have the basic mvc project with the login screen set up. i created a new page, but when i run the site i can just paste the URL of the new view and navigate there and it doesn't redirect me the login screen. what's the best way to lock down the rest of my site once i am using forms auth? thanks ...

How do I return a method paramenter with RedirectToAction

I have two method signatures at the moment. public ActionResult Edit(bool? failed) [AcceptVerbs(HttpVerbs.Post)] public ActionResult Update(FormCollection collection) In the Update method when the password update fails I want to return to the Edit action with failed == true. However using the line return RedirectToAction("Edit", tru...

.NET: How to access ExceptionContext object from Exception object

Hello all, I'm writing a custom error-handling method, and am passing it an Exception object. I need to be able to access that Exception's ExceptionContext object, so I can set a property to true before I execute the Error view. Does anyone know how to get to the ExceptionContext, given just an Exception object? For reference, the reas...

ASP.NET MVC 2: What does the C# View look like that edits nested Entities?

I tried numerous times over the last few weeks to get a server side MVC 2 view to work with objects with nested IList elements without much success. I am missing some fundamental understanding that I hope this question resolves. What I want is a form that shows a list of product where you can change information in-line, including a hie...