asp.net-mvc

Why can't I use C# 4 default parameters in Mono?

Mono works fine with my app, but when I try to compile a function like int Yo(int a, int b = 1) { // blah... } It doesn't work, it says that "Default parameter specifiers are not permitted" According to Mono's website The Mono C# compiler is considered feature complete for C# 1.0, C# 2.0 and C# 3.0 (ECMA). A preview of C# 4...

HTML markup rendering issue in ViewData? Also, MultiView functionality in MVC?

Hi, i'm trying to populate a ViewData instance with html markup like shown below. When the page renders, the html tags get rendered as text and not html markup. Anyone know why? Controller code: if (user.ActivationStatus == false) { ... ViewData["Message"] = "<p>Your account has been activated, you're good to go.</p>"; } el...

asp.net mvc cms

Hi. I am little bit confused by the concept of cms in asp.net mvc application. The question is the following: How can I add controllers and some processing in the view page in the cms? For instance in cms I create a page called "Account Details". For this logically I need a controller that would receive and process the request. The proc...

ASP.NET MVC: How to get Request.QueryString value when routing

Let's say I have the following rule routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); And in the controller public ActionResult For...

Overriding AuthorizeCore in custom Authorize attribute results in "no suitable method found to override" error

I'm trying to build custom AuthorizeAttribute, so in my Core project (a class library) I have this code: using System; using System.Web; using System.Web.Mvc; using IVC.Core.Web; using System.Linq; namespace IVC.Core.Attributes { public class TimeShareAuthorizeAttribute : AuthorizeAttribute { protected override bool Aut...

T4MVC and named parameters

I'm running into an error with T4MVC and named parameters. I have a controller: public class ProductsController : Controller { public virtual ViewResult List(int page = 1) { // foo.DoSomething() } } It seems T4MVC creates an overload List() as well. The result is that calling myProductsController.List(3) correct...

Is it possible to map complex types with SolrNet

Hello, I am using Solr and SolrNet for some simple scenarios in an ASP.NET MVC application. For one to one mappings, where I am mapping a single POCO to a document, everything works very smoothly. However, I'm wondering if it is possible to map more complex scenarios like the following. Essentially I have an Auction class which contains ...

How to persist a value in MVC partial view?

I have a search box that is implemented as a partial view. I would like the last searched value to remain (think of Yelp, where the location is always there, regardless of the page you are viewing). I am thinking of storing this in a cookie, but I am not sure where to add the code to read the cookie and add the value to the view model. A...

How can I convert an enumeration into a List<SelectListItem>?

i have an asp.net-mvc webpage and i want to show a dropdown list that is based off an enum. I want to show the text of each enum item and the id being the int value that the enum is associated with. Is there any elegant way of doing this conversion? ...

Resolve Array with Ninject

In Ninject there's automatic implicit self-binding for concrete types. So without further configuration I can resolve every type in my application, like: Foo foo = Kernel.Get(typeof(Foo)); Now if I need an Array of Foo, how would I do that? Foo[] foos = Kernel.Get(typeof(Foo[])); // does not work EDIT: For clarification, here is, ...

Return a PartialView from $.Ajax Post

I have the following code; $.ajax({ url: "/Home/jQueryAddComment", type: "POST", dataType: "json", data: json, contentType: 'application/json; charset=utf-8', success: function(data){ //var message = data.Message; alert(data...

How to use AJAX Post to invoke ASP.NET MVC Controller action and return new View?

I am working a site in ASP.NET MVC where the user is presented with a calendar, and clicking on a particular calendar date invokes the following function: function selectHandler(event, data) { var myRequest = new Request.HTML({ url: '/Calendar/EventList', method: 'post', data: ...

using different site.master files for themes

is having different site.master files common practices for theming. right now i have my menu system and different links and styles based on different ".master" files in an asp.net-mvc site. another developer thought that was a strange approach and i wanted to get some thoughts from the community. ...

How to display Images using HtmlHelper Class- ASP.NET MVC

Hi guys, I am currently stuck with this problem of displaying an image using HtmlHelper class. Here is what i have. I have a custom HtmlHelper class which supposed to display an image: public static string Images(this HtmlHelper helper, ......){ var writer = new HtmlTextWriter(new StringWriter()); byte[] bytearray = ... // so...

How to pass more than one parameter to View from Controller

I have an ActionResult in my HomeController defined to return JSON. The JSON is used in my View to render a jqGrid. This works perfectly. In addition to the JSON being returned, I need to also return other data (i.e. a decimal value that is not part of the JSON). What are ways I can do this? I am fairly new to MVC. Thanks for any he...

can .net mvc routing cause javascript errors

Hi guys, now a days i m having hell a lot of trouble using routing infrastructure of asp.net mvc2. i have following routes registered in my global.asax file routes.MapRoute( "strict", "{controller}.mvc/{docid}/{action}/{id}", new { action = "Index", id = "", docid = "" }, new { do...

How to handle exception in Flush phase?

Hi, how can I handle exception that is thrown in NHibernate method Flush? I have a action for deleting objects. It loads the objects from repository using posted ids and calls repository.Delete(obj). Leaving aside that my mapping in NHibernate is not complete and the delete results in "The DELETE statement conflicted with REFERENCE cons...

How to get IntelliSense for Razor View Engine

Hi, Just installed Microsoft Visual Web Developer 2010 and trying to create an MVC application with Razor View Engine. When opened a ".cshtml" file, I am not able to get colors for syntaxes in editor and also intellisense is not appearing. Is there any option I explicitly need to enable it? ...

how asp.net mvc globalization work with my own ResourceProvider

i create a new class which inherite the IResourceProvider,and register it in web.config <globalization resourceProviderFactoryType="xx.xxx.xxxx" uiCulture="auto" enableClientBasedCulture="true"/> this new class just implement public GetObject(string resourceKey, CultureInfo culture) { .... } which will get globalization text fr...

asp.net mvc 2 custom service account

I'm trying to deploy ASP.NET MVC 2 Silverlight application with custom service account. I did the following: 1) Domain user account (myAppUser) was created. Domain controller is different from the web server to which I'm trying to deploy my app. 2) On the web server I run the following command: aspnet_iisreg -ga myDomain\myAppUser w...