asp.net-mvc

Asp.Net-MVC application dying

I have a strange issue with an Asp.NET MVC application. Using Asp.NET MVC 3 Preview 1 on IIS 7.5 - Integrated After building the application everything runs fine. Then after some random amount of time (or sometimes after updating a view or js file) the application dies. Meaning, requesting the root page, I get the 403 error and reques...

asp.net mvc .ajax error catching

I'm having some issues catching error messages from a controller via .ajax error. The script is called by a jQuery UI Dialog popup. Any help would be appreciated. Here's the code snippet from my controller Response.StatusCode = (int)HttpStatusCode.BadRequest; return Content("There was an error in your request.",...

ASP.NET MVC 2 and request client certificate (Smart Card authentication)

I need to capture user's X.509 certificates from their cards and map to a user table for forms authentication in ASP.NET MVC. I have created an MVC (ver 2) project in VS 2008, configured to run as a virtual directory under the Default Web Site in the local IIS on Vista using the default template but added RequireHttpsAttribute to the Ac...

jQuery UI Dialog + Validate

I'm having trouble in validating a jQuery UI dialog using Jquery Validate upon clicking Save. Here's my code to create Jquery dialog. It loads the dialog from a target a href URL: $(document).ready(dialogForms); function dialogForms() { $('a.dialog-form').click(function() { var a = $(this); $.get(a.attr('href'),function(resp...

Paypal express payment

Does anyone can give any sample on using the paypal express payment feature with asp.net mvc2? thanks ...

javascript object System.Collections.Generic.List`1[System.String]?

In MVC, is it possible to pass an array of string (List<string>) from C# code to viewdata and then retrieve the value in the view? e.g: C#: List<string> names = new List<string>(); names.Add("a"); names.Add("b"); ViewData["names"] = names; MVC view: <script type="text/javascript"> var nameList = '<%= ViewData["names"] %>'; </script>...

nhibernate Could not initialize proxy - no Session +asp.net mvc

In action I taken some data from db. Now in view I want to take value from one field which is referenced from other table with lazyload, by I get this error: Could not initialize proxy - no Session I wonder what I can do now. public ActionResult Index() { using (NHUnitOfWork.Start()) { va...

Property in base controller to be used in the view

I am using MVC 2. I have a BaseController class that every Controller uses. In this base controller class there is a property called IsAdministrator. I need to use this method in my view's HTML part. How would I do this? EDIT: My property in my BaseController is defined like this: public bool IsAdministratorUser { get { return ...

ASP.NET MVC 3 Razor performance

I've made a simple hello world project in asp.net mvc2,3 aspx and 3 razor and benchmarked them. What I see is: asp.net mvc 2 aspx : 4200 request per second asp.net mvc 3 aspx : 3200 request per second asp.net mvc 3 razor : 1700 request per second What's wrong with razor, it's so slow? Update: I've redone the test. All 4 test virtual...

get value from custom attribute in editor template

at the moment I have this: in the ViewModel: [MyCustom(Foo = 23)] public int CountryId { get; set; } in the Editor template: <%= Html.TextBox("", Model) %> how can I get the value (Foo=23) from my custom attribute (MyCustom) into the editor template ? ...

Non-selectable drop down list

Is there any way to have a drop-down list in which non of the items are selectable? So basically, I'm just looking to use it as a way of showing/hiding a list. I don't want any hover highlighting and I don't want to be able to change the selected item. Could you suggest if this is possible, or if anyone has any other ideas to achieve so...

ASP.NET MVC using the Repository Pattern

Currently im using EF and using its datacontext directly in all of my actions, but since i started reading about loose coupling and testability im thinking that thats not the best way to go. Im trying to understand all the pro's and con's before i start refactor all my current code. Problem 1: Considering that every entity needs its own...

ASP.NET MVC Html.DropDownList populated by Ajax call to controller?

I wanted to create an editor template for a field type that is represented as a dropdownlist. In the definition of the editor template I would like to populate the DropDownList using a call to an action on the controller returning the results as JSON - Any ideas how to do this? E.g something like: <%@ Control Language="C#" Inherits="S...

How do I handle an exception in an ASP.NET MVC controller factory

I have an ASP.NET MVC 2 application with a custom StructureMap controller factory to handle dependency injection for my controllers: public class StructureMapControllerFactory : DefaultControllerFactory { public override IController CreateController(RequestContext context, string controllerName) { Type controllerType = b...

How to write integration and system tests in Asp.net MVC

My application I have an application design that looks like this: web application layer - asp.net MVC app with controllers and views that use POCOs and call services service layer - business processes that use POCOs and call repositories data layer - repositories that use POCOs and communicate with the model in the form of EF model wh...

Integration tests implementation

I have a tree layered app web app (asp.net mvc for simplicity here), business services data repositories And I know there are four types of integration tests: top down bottom up sandwich (combination of the top two) big bang I know I would write big-bang tests just like unit tests but without any mocking so I would employ a backe...

Is it possible to change the rewrite rules in asp.net mvc web.config using code?

I want to be able to add/update/delete rewrite rules from the web.config. Is this possible and are there any gotchas? ...

asp.net mvc - show content from string with html

in my Model I have a string property Feeds with value like that: <img src="/Images/Company/twitter.png" style="border:0; vertical-align:text-bottom;"/>&nbsp;<b>9/29/2010 1:01:33 PM</b><br/>How to get started building rich #VS2010 #VSPackage based extensions - <a href="http://bit.ly/a8ksc1" target="_NEW">http://bit.ly/a8ksc1&lt;/a&gt;&lt...

mvc - Storing checkbox states in multipage grids

While there are similar questions here, none gave a complete answer, so I am posting a new one. I have a paged grid - jqgrid - which receives data from server by ajax, N rows (10, 20 and so on, depending on the user selection) each time. There is a boolean value in the grid row model, which is transformed into a checkbox in the displaye...

Getting all selected checkboxes from a FormCollection

I have a form which contains a whole bunch of checkboxes and some other types of control too. I need to retrieve the names of each selected checkbox. What is the best way to do this? Can I do it with a linq query maybe? So in pseudocode, I'm looking to do something like this: var names = formCollection .Where(c => c is ...