asp.net-mvc

How to mock the controller context with moq

I am trying out the MOQ framework and up now I have hit a barrier. The following unit test fails because the actual value of the ViewName property is an empty string. Could anyone point me in the right direction please as to why this is not passing the test? [TestMethod] public void Can_Navigate_To_About_Page() { var request = new...

SelectedItem not being remembered in SelectList in ASPNET.MVC

I have the following code which is meant to populate a dropdown with a bunch of integer values and make the currently selected value (in this case, 13) be the selected item. I've used the same technique but for string values and it works great, remembering each time when I get to the view what the current value is. In controller: va...

Need ASP.Net/MVC Rich Text Editor

I'm looking for a "simple" RTE editor for a MVC application I'm programming. The editor running the Stackoverflow message editor is almost exactly what I'm looking for. We don't need anything as fancy as FCK's editor. Any suggestions? Thanks in advance. Tom ...

WCF Client Instantiation

I have a mvc controller class that uses a WCF service(WSHttpBinding), sometimes multiple calls within one http request, and want to know how expensive it is to create a client for that service. Is it ok to create an instance of the client for every call or should I create a member variable in the class? public class RingbacksController...

NHibernate Linq Session Management

I'm checking out Linq for NHibernate 2.1 to use in an ASP.NET MVC application and I am trying to figure out session management. As a first experiment I am trying to modify the SportsStore application from Pro ASP.NET MVC Framework. This sample app uses Linq to Sql so I thought it would be a good exercise. I have NHibernate 2.1 accessing ...

Benefits of MVC over MVP

Possible Duplicates: What are MVP and MVC and what is the difference? mvc and mvp pattern Folks, What are some of the benefits of using MVC over MVP? I like that I don't have to use a framework for MVP and can be implemented via interfaces and classes. I still get the separation of concerns that MVC has and I get unit testi...

Calling UpdateModel with a collection of complex data types reset all non-bound values?

I'm not sure if this is a bug in the DefaultModelBinder class or what. But UpdateModel usually doesn't change any values of the model except the ones it found a match for. Take a look at the following: [AcceptVerbs(HttpVerbs.Post)] public ViewResult Edit(List<int> Ids) { // Load list of persons from the database List<Person> peo...

How do I tell if a site is being hosted in the ASP Development Server?

Is there a way to do this at runtime? ...

Error downloading files from asp.net mvc web application

I am having this really weird issue with downloading files from within ASP.Net MVC (not downloading FROM the app, TO the app) and hope someone can help me out. This bit of code running in a controller: using (var wc = new WebClient()) { var siteText = wc.DownloadString("http://www.google.com"); re...

oAuth ASP.NET Membership Provider

Are there any recommended resources for implementing a custom membership provider that uses oAuth? The goal would be to have users to log into my ASP.NET MVC application using their existing oAuth credentials. After the user is authenticated, I'd then like to leverage the built-in ASP.NET authorization features. Thanks. ...

How does the NerdDinner example's Dinner.GetRuleViolations function return a list?

From what I've read, yield return <value> jumps out of the function the moment the line is executed. However, Scott Guthrie's text indicates that var errors = dinner.GetRuleViolations(); successfully pulls out a list of all the rule violations even though GetRuleViolations is a long list of if(String.someFunction(text)) yield ...

An array or Generic collection?

I need to pass a list of Days (number and name) to an view! Whats the best way to do this? I was thinking of creating a generic collection, but not sure how? or an array? ...

Execute code on every request in ASP.NET MVC

I have a controller that all my controllers inherit from and I need to execute some code for every controller request. I tried the following: protected override void Execute(System.Web.Routing.RequestContext requestContext) { if (Session["mallDetected"] == null) { Session["mallDetected"] = DateTime.Now.Ticks; ILi...

ASP.NET MVC runtime installation requirement in "test" server

Hi, I have an ASP.NET MVC application, and i have deployed it locally in my box. Now if i want to deploy it in a "Test" server (which is a tightly controlled environment), what do i need to install in the test server at the minimum - i.e. on top of the pre-installed ASP.NET 2.0 and .NET framework. Do i need to isntall ASP.NET MVC runti...

RuntimeType instead of Type in C# Unit Test

Hi, In one of my unit tests I want to check if all public methods are returning type of ActionResult. Here's my test method: [TestMethod] public void Public_Methods_Should_Only_Return_ActionResults() { MethodInfo[] methodInfos = typeof(MyController).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFl...

Deploying ASP.NET MVC projects into test server

This is a general question regarding deploying an MVC asp.net app into a test server. How do you do it? I tried to publish and deploy an mvc app into test server (under tight control), and the VS.NET complained that it was not able to update the remote IIS server for creating the virtual directory etc there, although the remote machine...

Unable to overwrite uploaded images in C# using the Image object

I am trying to create a utility in C# using the MVC framework where a user uploads a picture which is used to crop pieces out of to be used as thumbnail icons (only one user at a time will be doing this at any given time). The user can then upload a different picture and continue cropping. I have a controller action that handles the fi...

How to do pagination and filtering in MVC applications

I am using the example martijn Boland's to page. The url of my app changes when I click on the page numbers: http://localhost:1202/Issue?page=6 So far so good. The problem is when I add a dropdownlist that submits on change, I can not page as well as filter. If I change my dropdown, I should pass the projectId in the querysting, my...

ASP.NET MVC C#: Object reference errors when going to view record details

I'm a .NET and MVC newbie, and learning it for the first time after suffering too long with ASP, and it's about time I converted over to make my job of building web applications that much easier. I've been going through Stephen Walther's helpful video tutorials to get my head around most things, and I'm making good progress thus far. Wh...

ASP.NET MVC $.ajax POST doesn't submit correctly

In javascript I have the following: $.ajax({ url: "/ajax/test", type: "POST", dataType: "html", data: '{"keyword" : "' + $('#tbxBrand').val() + '", "projectguid" : "<%= thisProject.ProjectGuid.ToString() %>", "userguid" : "<%= thisUser.UserGuid.ToString() %>"}', beforeSend: function() { }, ...