asp.net-mvc

TranslateAttribute for my asp.net-mvc site

In my current project I have a custom ViewData that has (amongst others) the following properties: CustomViewData + IList <Language> siteLangauges + Language CurrentLanguage + T9nProvider All my URL's go like this: http://someUrl.com/{siteLanguage}/{restOfUrlIncludingcontrollersAndACtions} I want to create an ActionAttribute ...

ASP.NET MVC - CustomeAuthorize filter action using an external website for loggin in the user

I have a CustomeAuthorize action filter that forwards the user to signin page if user is not authenticated. I apply this filter to actions or controllers. [CustumeAuthorize] public ActionResult MyAction() { //do something here return View(); } and the filter looks like this: public class CustomAuthorizeAttribute : ActionFilter...

Suggestions needed for handling dynamic redirect routes in ASP.Net MVC

I have a number of create and delete partial views that I want to reuse by calling from other views. The issue is that this requires me to pass the return route and routeValues to the create and delete controller methods so that they can generate an appropriate redirect back to the original view on success. I created some extensions and ...

ASP.NET MVC: setting objects in ActionParameters is adding them to the query string too

I have a controller method that looks like this: [AcceptGet] public ActionResult Index(SecurityMatrixIndexViewModel model) { if (model == null) model = CreateIndexViewModel(); return View(model); } In another controller method, I am redirecting to this Index action. I have an action filter attribute that takes a mo...

JQuery - add click event to LI or SPAN elements?

I am trying to add a click event to a LI element but it is not firing in the page. My page markup looks like: <div id="Navigation"> <ul> <li class="navPrevNext inactive">|&lt; First Page</li> <li class="navPrevNext inactive">&lt; Prev Page</li> <li class="navIndex selected" title="0 ">1</li> <li class="navIndex notselec...

How to add id HTML attribute in ASP.NET MVC w/ VB.NET

I am trying to add an ID HTML attribute to a form using ASP.NET MVC and VB.NET <%Html.BeginForm("Create", "Model", "", "", New With {.id = "CreateForm"})%> This gives me a type error, since .id is expecting an Integer, not a string. How do add an ID attribute to my form? ...

Does the asp.net RoleManager really cache the roles for a user in a cookie if so configured?

In my web.config I have the Role Manager configured as follows: <roleManager enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All"> however in our custom RoleProvider it would seems that the GetRolesForUser meth...

MVC Routing - Use route part to switch views...

I have a series of URLs that look like /Catalog/Ajax/Update/{ViewToUpdate}?var1=a&var2=b&var3=c Currently I've setup several routes - one for each {ViewToUpdate} and what I'd like to do is pass the {ViewToUpdate} to my Action handler so I can condense my code. Instead of: public ActionResult AjaxUpdateNavigation(string var1, string...

How to use form authentication with asp.net mvc?

I want to use forms authentication in asp.net mvc applications. I have searched a this things but could not get satisfactory answer so can any one please give me brief idea for this. I am a newbie and playing around asp.net mvc. Please also describe how many authentication is possible with the asp.net mvc. ...

How can i use caching api in asp.net mvc?

ASP.NET Offers great caching api with lots of functionality. Can anybody answer me that how i can use the caching api with the asp.net mvc. ...

Are Simple Controllers Without Models a Valid Architecture?

I'm in the process of converting parts of an application to use ASP.NET MVC from WebForms. The idea is that when possible I use MVC for new development. My problem is this: Doing it this way means that my Models are not completely implemented in MVC. Let's say that my WebForms application has a robust Widget Management page. I'm add...

What is the best way to learn JQuery?

Hi I am newbie to ASP.NET MVC and jQuery. What is the best way to learn jQuery? Are there any good links, blogs, screencasts? Thanks in advance. ...

ASP.NET MVC and Idisposable

How i can use IDisposable interface with asp.net mvc. ...

Where should I place a check that may redirect a request?

I need to redirect users to the Change Password page if their password has expired. I want to place this code in one place so that any request can be redirected to the change password page. I've looked into extending the AuthorizeAttribute, and overriding OnActionExecuting, but neither work/allow me to short circuit the routing logic t...

LINQ to Entities Entity Initialization

In the tutorials for ASP.Net MVC, the LINQ to Entities code looks like: public class MyController : Controller { private Models db; public ActionResult Index() { db = new Models(); var foo = (from f in db.foo select f).ToList(); return View(foo); } } I'm guessing this has something to do with t...

Custom a catch-all parameter in routing

Hi Geeks, I recently want to have a special routing rule : {*whatever}/details/{Id}/{itemName} I know an exception will be thrown once I run the application. In my application, for example my url pattern is www.domain.com/root/parent/child/.../child/details/30/itemname but the current routing doesnot support this. How can custom the r...

MVC versus WebForms

It seems to me like there's a lot of sheeping going on, with everyone jumping on the MVC bandwagon. Almost everyone is declaring WebForms as evil and satan without much persuasion. Then they go on to say that Controls are evil and they shouldn't be in a Web app. How are you going to show anything without any controls? I remember when W...

getting mvc on shared host to work

Any idea on how to get my asp.net mvc website to work on a webhost that's running asp.net 3.5 but maybe not IIS 7? (I think they might be on IIS 6) I am on Crystal Tech and my home page shows up just fine but all other requests give me a 404 page not found error. Note: I already follow these instructions but it's still not working htt...

Stream zip file MVC.NET start streaming

I'm trying to create a method which continually streams a zip file as a user downloads it (so that there is no wasted streaming) I added a thread.sleep to simulate latency public override void ExecuteResult(ControllerContext context) { HttpResponseBase response = context.HttpContext.Response; response.Clear(); r...

I've decoupled my user model from the main domain model that represents a 'person' and wonder how to retrieve personalized user data in the controller context.

Example: [Authorize] public ActionResult Index() { var person = _userPersonalizationService.GetPersonForUser(User.Identity.Name); var campaigns = _campaignRepository.GetCampaignsByCompanyId(person.Company.CompanyId); return View(campaigns); } Basically every user is tied to a person model, and in this instance, I want the ...