asp.net-mvc

T4MVC Links for SEO

Hey guys, I'm trying to switch our links over to T4MVC, and I'm having a small problem with parameters that aren't part of an action's signature. We have a route that goes something like this: http://www.mydomain.com/{fooKey}/{barKey}/{barID} ==> leads to BarController.Details(barID). fooKey and barKey are only added to the links fo...

How can I tell if my controller action is being called from another controller action?

Is there any easy way to distinguish between an ASP.NET MVC controller action being hit "directly" due to a client web browser request, and being hit by virtue of a Controller.RedirectToAction call or a RedirectToRoute result? ...

Rename field in JsonSerializer

Hi, I have a class library that I need to output via a JsonResult in the ASP.NET MVC framework. (JsonResult uses the JsonSerializer to produce its output.) I discovered through reading the documentation that if you put [ScriptIgnore] on a public property/field, it will not get serialized, much like [XmlIgnore] for the XML serializer. ...

Running a custom VirtualPathProvider with a PreCompiled website

Hi, currently I have a custom VirtualPathProvider in a Asp.net MVC web application. This VirtualPathProvider checks the Area from the route "/{Area}/{Controller}/..." and uses the NameSpace.{Area}.Main.dll module to return the views that are contained in that assembly as Embedded Resources. This works great and I don't have to deploy a...

asp.net image in a form and HTTPPost

HI, I'm sure I'm missing something very obvious here so please forgive me. I'm using MVC 2 Beta and I have a model that has several properties, strings, ints etc. the usual stuff. It also has a byte array that contains an image. I have an edit action method on my controller decorated with a [HTTPGet] attribute. The method passes the m...

ASP.net MVC ERROR after deploying on the hosting web site

I get the assembly error Parser Error Message: Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. Any idea what needs to be included. ...

Learning ASP.NET MVC on Mac OS X

I realize this is a bit insane, C# being a Windows language and all, but I want to start learning C# mostly because I'm interested in ASP.NET MVC. I work as a web developer by day and my office is completely run on *nix machines. The developers and all other staff use Mac OS X and our servers are all some variation of Linux. To be hones...

Mvc ActionLink with javascript

Hi everyone, I'm working with MVC, I have a view with an ActionLink that calls an Action of my controller, my issue is when I want to call also a javascript function on the onClick() event of that action link (as that action link converts to html standart tag on execution time). How should i do this? what is the better way? Here is the...

ASP.NET MVC AjaxActionLink OnComplete and OnSuccess property and Jquery

Hi, I'm trying to create a dialog box in my ASP.NET application with an AJAX ActionLink. The Ajax ActionLink inserts a partial view into a div in the current view. I've called a function OnComplete (and I've tried OnSuccess, too) that calls the dialog function for JQuery UI, like so: function() loaddialog { $("ContainerwithInsertedPa...

Unit Testing Controller Actions that call IsAjaxRequest()

Some of my controller actions need to respond with different ViewResults depending whether or not they were called by an AJAX request. Currently, I'm using the IsAjaxRequest() method to check for this. When this method is called during a unit test, it throws an ArgumentNullException because the HTTP context is missing. Is there a way t...

What's the difference between a ViewModel and Controller?

What are the responsibilities of one vs the other? What kind of logic should go in one vs the other? Which one hits services and databases? How do I decide if my code should go in the viewmodel or the controller? For the record, I am using ASP MVC, but since the question is architectural, I do not believe it matters what language or fra...

What’s the difference between a ViewModel and Controller in ASP MVC

What are the responsibilities of one vs the other? What kind of logic should go in one vs the other? Which one hits services and databases? How do I decide if my code should go in the viewmodel or the controller? for the record, I am using asp mvc ...

Is it OK to send a 301 redirect with an action filter?

I'm writing a new asp.net mvc application and I've been toying with the idea of allowing my user to post short, concise urls to content that he has posted. Those short url's will be handy in cramped spaces like Twitter and comment areas. I like this idea as I'm not a huge fan of url shorteners because they're so vague and you're never re...

How to create MVC HtmlHelper table from list of objects

I am trying to create a specific HtmlHelper table extension to reduce the spaghetti code in my View. Taking a list of domain objects I would like to display a table that is a little bit more intelligent in using the properties of the domain object as columns. In addition, I would like to disable showing of some properties as columns. An...

How do I validate a property that needs to access a repository in xVal?

I'm trying to use xVal to validate the registration of a new user. I've ran into a buzz saw when trying to implement the logic that checks to see if the user name that the new user is trying to register with is already taken. I can't seem to find a way to accomplish this without having my User entity have a dependence on my UsersReposito...

using Url.Content to display the file content with .net mvc

In my .net mvc application, I need to dynamically insert contents from local files into a View page. So that the contents from different files can be display with the same style. So I created a controller called StaticController and an action called General. Following is my code: public class StaticController : Controller { public ...

asp.net mvc is not using the controller factory specified

I am using ASP.NET MVC Preview 2 that is installed with VS2010 Beta 2. I am hooking up WindsorControllerFactory like so: Container = new WindsorContainer(); Container.RegisterControllers(typeof(HomeController).Assembly); ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(Container)); My HomeController has one ...

.net mvc routing greedy regex

In my global.asax.cs file. I add an entry routes.MapRoute( "Static text", "Static/General/{filePath}", new { controller = "Static", Action = "General", filePath = "" }, // new { filePath = @"xxxx" } // greedy regular expression ); What I want to do is to take the content f...

NHibernate -failed to lazily initialize a collection of role.

I have the following seemingly simple scenario, however I'm still pretty new to NHibernate. When trying to load the following model for an Edit action on my Controller: Controller's Edit Action: public ActionResult Edit(Guid id) { return View(_repository.GetById(id)); } Repository: public SomeModel GetById(Guid id) { using ...

ASP.Net + MVC + VS 2008

Can anyone advise what is the best way of client and server side validatio. Either we go for Data Annotation if it support with VS2008. Or go with Jquery ... Can anybody guide me as well any example, link is appreciated. ...