asp.net-mvc

How to show/hide selected object like div?

So i'm trying out MVC after only playing with it some time ago. Need to find the best way to selectively show and hide sections (divs, etc) on clicking or changing a value of a control, but not having to post back, i.e. javascript? Any suggestions. ...

asp.net mvc Not authorized response is blank page ??

If i'm not authorized on a controller action, i am getting a blank page and no error message? I'd like to display a message of some sort, Here's my setup: class MyAuth : AuthorizeAttribute { protected override bool AuthorizeCore(HttpContextBase httpContext) { if (!httpContext.User.Identity.IsAuthenticated) re...

I need More information on HandleError

Hi I am not sure what the difference between the different ways to HandleError. In the asp.net mvc(default project) they put this on top of the class [HandleError] So I was reading some blog and the person says this "....tells the framework that if an unhandled exception occurs in your controller that rather than showing the default...

Asp.Net MVC - ValidationMessage() - how to prevent HTML escaping?

In my scenario I'd like to display a text with URL link within validation message attached to form element on MVC view. I'm using ValidationExtensions.ValidationMessage extension method, like this: <%=Html.ValidationMessage(Model.Name) %> The behavior I'm seeing is that validation message is HTML escaped, what effectively prevents me ...

Detect View or PartialView in controller

In a controller can I detect if I'm "controlling" a View or a partial view? I have a shared controller that sits between any controller and Controller, there are things I would only like to happen if its a View rather than a partial view. Ideally in protected override ViewResult View(... Thanks, Nath ...

Refresh PartialView via jQuery following Ajax Post

Does anyone have the special sauce for following a jQuery Form ajax post to a controller method forcing a refresh to a PartialView existing on the same page? Does that involve bringing partial HTML back and appending or can I simply somehow cause that PartialView to refresh magically? Thanks in advance. Doug Here is my RenderPartial w...

MVC form action

I have a edit View - Product/Edit/1 1 being the Id of the Product.How can I set the action of the edit post in the View to the POST edit action [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(int Id, FormCollection collection) The form tag is prepopulated as but I want to set it to /Product/Edit/1 I am using this <%u...

how to catch exception of MVC view?

In controller, try...catch can catch exception. How to catch exception in view? for example, a view may have code like: <%= Html.Encode(Model.MyID)%> If Model is null, you will get exception when access the view. where to catch the exception and redirect user to a error page with user-friendly error message? ...

Is there a way to pass (or access) a controller's ModelState to an ActionFilterAttribute?

I have a custom validation attribute derived from action filter attribute. Currently the attribute simply sets an ActionParameter value indicating if the item validated was good or not and then the action has to have logic to determine what to do with information. public class SpecialValidatorAttribute: ActionFilterAttribute { p...

ASP.NET MVC - How can I pass FormCollection data in a post to another Action?

Hi everyone! I have a page "Results" with a form and when "submit" is clicked, the form is submmited to another Action. So far, so good... But, this works fine just if user is logged in. If not, he will be redirected to "Login" page and my FormCollection loses its data. Is there a way to persist this data without using TempData?? Tha...

Bind a routevalue to a property of an object that is part of viewmodel

I have the following route: routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults ); and I...

SiteMap HtmlHelper ASP.NET MVC

I've rewritten this post to make it more simple. This is the code I've got (a HtmlHelper): using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Runtime.CompilerServices; using System.Web.Mvc; using System.Text; using System.Web.Routing; namespace Intranet.Helpers { public static class Me...

How can I create a single cookie and save multiple pairs key/values to it?

Hi! In ASP.NET MVC, how can I create a single cookie and save multplie values to it? Thanks!! ...

URL Rewriting multiple folders to one folder

Hi, I'm using IIRF on IIS6/Server03 with an MVC app in the root of the server and a virtual directory for the wordpress blog/cms. I'd ideally like the urls as follows... domain.com/ domain.com/wpcategory/ -> rewritten from domain.com/blog/wpcategory/ domain.com/wpcategory/wparticle/ -> rewritten from domain.com/blog/wpcategory/art...

ASP.NET MVC - How to handle an expired password?

What's the best way to handle an expired password in an ASP.NET MVC application? Let me explain - ASP.NET MVC is obviously set up (both in the barebones app the NerdDinner example) to handle the following scenarios: Register new users Allow them to change their password Log in using a valid account/password What it doesn't have is a...

Issues using openid-selector/ dotnet openid

I'm using openid-selector based UI to authenticate user using dotnet openid API. I'm having a small issue, when i select google and cancel and close browser and then open link and select yahoo it redirects me google but not yahoo. i checked that when i click button at bottom on browser status bar it shows correct parameter being sent to...

Domain Driven Design newbie, please explain 'value objects' and 'services' briefly

I am reading http://en.wikipedia.org/wiki/Domain-driven_design right now, and I just need 2 quick examples so I understand what 'value objects' and 'services' are in the context of DDD. Value Objects: An object that describes a characteristic of a thing. Value Objects have no conceptual identity. They are typically read-only objects an...

Difference Between $.getJSON() and $.ajax() in jQuery

I am calling an ASP.NET MVC action public JsonResult GetPatient(string patientID) { ... from JavaScript using jQuery. The following call works $.getJSON( '/Services/GetPatient', { patientID: "1" }, function(jsonData) { alert(jsonData); }); whereas this one does not. $.ajax({ type: 'POST', url: '/Services/GetPatient', data:...

Asp.net MVC Membership starter kit

I have downloaded and installed membership starter kit from codeplex. Now when I create new project I don't see MVC mebership starter kit in list of templates. How do I create new project based on this starter kit ? ...

How to redirect to error page in view in MS ASP.NET MVC?

In Controller, RedirectToAction("Error") can redirect to error page. How to write code in view code to allow the page redirected to error.aspx view? ...