asp.net-mvc

ASP.NET Routing Question

Why is this: http://MySite.com/Project/24/Search/32/Edit/49 preferred over this? http://MySite.com/Project/24?Search=32&Edit=49 ...

How to return bool from MSFT-MVC action to jQuery $.ajax()

I am calling a MSFT-MVC action using jQuery $.ajax() public bool SetActivePatient(string patientID) { which returns a boolean. The $.ajax() call is always firing the error option. $.ajax({ type: 'POST', url: '/Services/SetActivePatient', data: { 'patientID': id }, dataType: 'text', success: function(returnVal) { if (ret...

ASP.NET MVC: avoid tight coupling when binding form POST to parameter

Let's say I have an interface like: interface IThing { int Id { get; set; } string Title { get; set; } } And in ASP.NET MVC I have a form that posts to a controller action like this: [AcceptVerbs(HttpVerbs.Post)] public ActionResult NewThing([Bind(Exclude = "Id")] SimpleThing thing) { // code to validate and persist the...

How to Unit Test a custom ModelBinder using Moq?

I'm having some difficulty writing some Unit Tests to test a custom ModelBinder that I created. The ModelBinder I'm trying to Unit Test is the JsonDictionaryModelBinder that I posted here. The problem I'm having is getting the Mocking all setup using Moq. I keep getting Null Exceptions due to the HttpContextBase not being Mocked correct...

Creating ASP.NET MVC application with different product categories

A website like www.halifax.co.uk offers different product categories, like mortgages, savings.. Mortgage and savings products will hold different data fields. This does not fit with having a single products controller that would be used in the majority of cases. A single products controller or a controller for each product category? ...

Creating an AJAX toggle-image in ASP.NET MVC

So I wanted to create a toggle-button for a table, where I can make an async call to update a database record (enable/disable). After some trial and error, I have managed to get it working - but it feels like there must be a more elegant way. I don't like repeating my image-tag in my controller, obviously... How can I avoid that in ...

MySql or SQL Server?

Currently I have an Asp.net website. Basically it was a prototype that showed to my school who are interested in my product. I decided to use this as my industry project that I must complete to graduate. That way if my school decides not to go with it I still can host it myself and target individuals and I complete my requirement for m...

Cannot use Html.ActionLink in asp.net mvc spark files

I'm using the spark view engine with my asp.net mvc application. In my aspx pages, I can succesfully use Html.Actionlink, but when I attempt it in spark files, it doesnt show up in intellisense, and when i try to run it anyway, i get: Dynamic view compilation failed. c:\Users\midas\Documents\Visual Studio 2008\Projects\ChurchMVC\ChurchM...

How to speed up Visual Studio Webserver (Cassini)?

Hi, for my webapp the integrated Visual Studio Server (Cassini) ist much slower than IIS. How can I speed up Cassini so that i dont have to wait for 3s for every small page? ...

What is the best way to expire client session?

In my asp.net mvc where to put code to expire browser session when server session expires. Can I use any action attribute? Which should be the best? ...

Passing viewdata back to a controller for use with dropdown list

Hi, I have a page which has an Html.DropDownList which takes in a viewdata parameter. The issue is that when a user clicks save it verifies the model with a call to ModelState.IsValid if this fails I want the page to display the errors (this works fine) The issue I have is that the viewdata for the DropDown is lost, this means that I d...

How Do I call A wcf Web Service from jquery?

How can i call a wcf service from jquery (i am using asp.nt mvc). This is what i used to do with asmx webservices : $.ajax({ type: "POST", url: "Services/MyService.asmx/DoSomething", data: "{}", contentType: "application/json; charset=utf-8", dataType: "j...

What do IO Error and Stream Error mean (Flash)

Hi, I'm trying to do an http post from flash on my website to a method in a controller (My site is on Asp.Net MVC) and I'm getting this error: Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: http://www.mysite.com/Home/DoSomething at Main/postToMyWebsite() Any ideas of why these errors happen and how to preve...

What is the proper way to do an http Post from Flash to an Asp.Net MVC Application?

Hi, Here are a few of the things I need to know: What do you put for the URLRequest? It's confusing me a bit since Asp.Net MVC is methods and not pages How do you assign parameters for the POST? How to you execute the URLRequest to complete the Http Post? Any information on how to do a Post from Flash to an Asp.Net MVC Application w...

Getting the name of the controller and action method in the view in ASP.Net MVC

Is there a way in a view in ASP.Net MVC to get the names of the controller and actien method that are using the view? ...

Linq to SQL Repository question

Hi Experts, I am working on a similar project like NerdDinner (www.nerddinner.com). I have similar tables, but I have used a generic repository (copied from here http://www.codeproject.com/KB/architecture/linqrepository.aspx). It seems working without any problem. Here are the codes. IRepository.cs using System; using System.Collect...

Should ASP.NET MVC developers really learn Ruby on Rails?

Hey guys, Today, I came a cross a blog post for David Hayden explaining why he thinks ASP.NET MVC developers should learn Ruby on Rails. Some of the reasons David mentioned: ASP.NET MVC was inspired by Rails and in order for me to be a smarter ASP.NET MVC Developer I feel like I need to know Rails. IronRuby is well on its way to...

When I click to open a ViewPage or a ViewUserControl Visual Studio 2008 hangs for me

When I double click on a ViewPage or a ViewUserControl in Visual Studio 2008 the whole application hangs for me, I have no idea why... The only error log I can find in the Event Log is this: .NET Runtime version 2.0.50727.3053 - Fatal Execution Engine Error (7A035E00) (80131506) For more information, see Help and Support Center at htt...

ASP.NET MVC: return Redirect and ViewData

Hi, I have a login box in my MasterPage. Whenever the login information is not correct, I valorize ViewData["loginError"] to show the error message to the user. Login is an action of the UserController, so the form that contains the login has action = "/User/Login". As a user can try to log in from any page, in case of success I redire...

asp MVC: Is it possible to determine how a controller method was called?

Is it possible for a controller method to return a view if called restfully and if called, via JavaScript, would return a JsonResult. My motivation is that I want to have the freedom to implement my view however I want to do this WITHOUT having to create two controller methods (one for each separate scenario...see elaboration below). I...