asp.net-mvc

ASP.NET MVC unit test controller with HttpContext

I am trying to write a unit test for my one controller to verify if a view was returned properly, but this controller has a basecontroller that accesses the HttpContext.Current.Session. Everytime I create a new instance of my controller is calls the basecontroller constructor and the test fails with a null pointer exception on the HttpC...

C#, Linq, Dynamic Query: Code to filter a Dynamic query outside of the Repository

If you do something like this in your Repository: IQueryable<CarClass> GetCars(string condition, params object[] values) { return db.Cars.Where(condition, values); } And you set the condition and values outside of the repository: string condition = "CarMake == @Make"; object[] values = new string[] { Make = "Ford" }; var result ...

How can I implement my own version of a MVC framework in ASP.NET?

Hi - I would like to know how I can go about implementing my own version of a MVC framework in ASP.NET? I know there already is Microsoft provided ASP.NET MVC framework, but I want to learn MVC and thought the best way would be to implement my own flavor of a MVC framework on top of ASP.NET. Any thoughts / guidance ? Also, can anyone po...

How to create dynamic view page in mvc2.0?

Hai,I am trying to create view page at run time means,when the user type some text in textbox at run time then the view page with that name should get created. Is this possible.If yes,then how?Please help me. ...

Could model unit tests be truly independent and how [ASP.NET MVC]

I am new to the whole unit testing stuff, so please excuse my lack of experience. I've read a lot of materials saying that no test should depend on others to do, i.e unit tests be completely independent form each other. Can you really do that in reality? I am having the following example: I have a few entity classes depending on each oth...

ASP.NET MVC app not browsing to pages only Index.aspx on root

Hi, I have an MVC 1.0 app just setup but it only shows the Index.aspx page of Home. Seems like the routing engine is not being engaged. I get a 404 error when i try to browse other pages. Any ideas why this might be? Malcolm ...

Arguments of using WCF/OData as access layer instead of EF/L2S/nHibernate directly

We develop mostly low traffic but highly specialized web applications. Normally we use L2S, EF or nHibernate as access layer and then throws Asp.Net MVC to it and in which for normal crud operations we query the ISession/DataContext directly but for more advanced functions/side effects we put it in a some kind of service layer. Now, i ...

asp.net mvc taking offline for testing

I need to test a feature in a live "asp.net mvc" web site and would want to block access to the site while testing, how would you recommend doing that? Is it possible to block access and still be able to test as an anonymous user? (I need to test the process as a user that's not logged in). ...

Assigning a MVC Controller property from Asp.Net page

I don't know if I've understanding MVC correctly if my question makes no sense, but I'm trying to understand the following: I have some code on a controller that returns JSON data. The JSON data is populated based on a choice from a dropdown box on an Asp.Net page. I thought (incorrectly) that Session variables would be shared between t...

ASP.NET MVC 2 validation LINQ to SQL

Currently I have a DataModel object which contains my linq to sql classes(a dmbl file). Currently I use a partial class to validate the incoming input. For example public partial class User : IEntity { public NameValueCollection CheckModel() { return GetRuleViolations(); } /// <summary> /// Method validates...

Tracing working ASP.NET MVC with IIS7?

From searching around it seems the old style trace.axd does work with MVC. Not sure how well, but people to appear to be using it. I am having difficulty getting running on my setup (IIS7, Windows Server, ASP.NET 3.5 with MVC 1.0. I have tried following classic the guidelines, but I get a trace not enabled message when trying to load tr...

Why user control with code behind file doesn't want to compile under MVC2?

I have user control in my MVC2 app placed in the Content folder (it's not supposed to be a view, just reusable part of the app). UserControl1.ascx looks like: <@ Control AutoEventWireup="true" Language="C#" CodeFile="~/Content/UserControl1.ascx.cs" Inherits="MVCDrill.Content.UserControl1" %> <div runat="server" id="mydiv"> <asp:LinkBu...

asp.net mvc post variable to controller

Hello fellow programmer I came from PHP language(codeigniter), but now I learning ASP.Net MVC :) In PHP codeigniter we can catch the post variable easily with $this->input->post("theinput"); I know that in ASP.Net MVC we can create an action method that will accepts variable from post request like this public ActionResult Edit(str...

mysql Command timeout error

I am converting my database from sql server 2005 to mysql using asp .net mvc. I have bulk data in sql server(around 4 lakh records), But i am facing command timeout/wating for comand timeout error which when i search on google can be given 65535 as its highest value Or can be given 0 if someone wants that comand should wait for unlimite...

How to set disabled in MVC htmlAttribute

When using an HTML Helper, what is the best method to set an attribute based on a condition. For example <%if (Page.User.IsInRole("administrator")) {%> <%=Html.TextBoxFor(m => m.FirstName, new {@class='contactDetails'}%> <%} else {%> <%=Html.TextBoxFor(m => m.FirstName, new {@class='contactDetails', disabled = true}%> <%}%> There must...

Displaying an asterix when using Html.LabelFor() with a Required property

I'm using ASP.NET MVC2 and Data Annotations. I've decorated a property in my buddy class with the Required attribute. Is there a way to get the Html.LabelFor() helper method to automatically display an asterix to signify that the field is required? Only ways I can think of to do this are: a) Extend LabelExtensions Or b) Manually ad...

MVC2 Routing Issue

I have a few routing issues with my ASP.NET MVC2 website and was wondering if there is a way I can get the runtime to simple list of all of the routes it thinks it understands. Some thing like the fubu diagnostics would be handy ... ...

asp.net mvc long operation

i need create an email list sending to many emails. what is best solution in mvc to call long time operation? better with example ...

MVC architectural question - Where should payment processing go?

This question is related to my ASP.NET MVC 2 development, but it could apply to any MVC environment and a question of where the logic should go. So let's say I have a controller that takes an online payment such as a shopping cart application. And I have the method that accepts the customers' credit card information: public class CartC...

Is it possible to bind data asynchronously between two dropdownlists in a view?

I'd like to achieve the following effect using ASP.NET MVC and JQuery. I've got a drop down list displaying a list of Countries. I want to make it so that when I change the value of the country, a new drop down list appears below it, showing a list of companies whose country of origin is the particular selected company. The thing is th...