asp.net-mvc

Passing ViewModel in ASP.Net MVC from a View to a different View using Get

I have a List View which has a strongly typed ViewModel which includes the entity list I am working with together with some other session-type stuff I am carrying aruound. On clicking an item in the list (an Html.ActionLink) to go to the Details view I can easily pass the entity id. But I also want to pass the rest of the ViewModel from...

Authorization and ASP.NET MVC Caching

I'm confused on ASP.NET MVC caching and authorization and in dire need of some clarification. My self-made authorization attribute inherits from AuthorizeAttribute. It's overridden AuthorizeCore() method runs every time, even if I set an [OutputCache] directive on a controller action. I got that part. Now the mind bender for me: Author...

Is Html.BeginForm() necessary?

What does Html.BeginForm() do and is it necessary? Sometimes I forget to put it on a form that takes user input but things still seem to work. What am I missing out on when I don't have it? ...

How to solve base Controller dependency injection for testing purposes?

I have implemented my mvc base controller called DefaultController using dependency injection pattern in order to be able to construct test cases. Example below: public class DefaultController : Controller { protected readonly ISessionHelper _sessionHelper; string _thisUserOpenID; protected IUsersRepository _UserRepository;...

Query Builder vs Linq to Entities

I have been hearing that the built in query builder for the entity framework is much faster to then Linq to Entities. Is this true? If so, can I use the query builder for any type of query? ...

asp.net mvc System.Data.Linq.DuplicateKeyException on update

Hello, I'm using asp.net mvc with linq to sql repositories and the following code is throwing an mvc System.Data.Linq.DuplicateKeyException exception on this._table.Attach(entity) My code is something like that: public ActionResult Edit(int id) { return View(_controllerRepository.GetById(id)); } public Actio...

How can I cache LINQ to SQL results safely?

I have an ASP.Net MVC web app that includes a set of Forums. In order to maintain flexible security, I have chosen an access-control-list style of security. However, this is getting to be a pretty heavy chunk of data to retrieve every time somebody views the forum index. I am using the EnterpriseLibrary.Caching functionality to cache ...

How does SelectByKey work in the Repository Pattern?

Hi, I'm implementing the repository pattern found here Implementing Repository Pattern With Entity Framework One of the methods he has is SelectByKey. In the comment called Key field impementation by [email protected], there was a suggestion to make it a little more generic of an implementation: I would like to add a simple mechani...

Dynamically loading view controls in a view page with asp.net mvc. Possible?

I'm trying find a way to do something with MVC that I was able to do with WebForms. I have a set of steps a user needs to go through to fill in data. In a previous case it was registering animals on an 'classifieds' site that was designed in webforms. For simplicity lets say it has 3 pages. Page 1 asks them what type of animal in a drop...

ASP.NET MVC Routing

What would be the most appropriate route for this URL? www.mysite.com/searchkey0 www.mysite.com/searchkey1 Where searchkey is the keyword for a search method? I tried the following route: routes.MapRoute( _ "SearchRoute", _ "search", _ New With {.controller = "Search", .action = "Search", .id = ""} _ ) ...

ASP.NET Application on 3 physical tiers

For clarity when I mention tiers in my question, I am referring to physical tiers (i.e. different servers for presentation, application and database) My company has a public facing website that is currently built as a typical 2 tier system (web server and database server). Soon a project will start in which we will be re-writing the wh...

Performing validation asp.net mvc without using models

Hello everyone, How do i do validation in mvc if I'm not using models? I'm directly obtaining data from the controller and displaying it. How do I validate ? Most examples seem to use the model to validate.... Would appreciate any help... Thanks. ...

Generate URL in HTML helper

Normally in an ASP.NET view one could use the following function to obtain a URL (not an <a>): Url.Action("Action", "Controller"); However, I cannot find how to do it from a custom HTML helper. I have public class MyCustomHelper { public static string ExtensionMethod(this HtmlHelper helper) { } } The helper variable has t...

Form in ASP.NET MVC (1.0) does not fire if "id" attribute is present (jQuery Validation requirement)

<% Html.BeginForm("Index", "Home", FormMethod.Post, new { id = "form_logon" }); %> or <form id = "form_logon", action="/Home/Index" method="post"> just don't work. Pressing a submit button if ID is present does nothing, while id is required for jQuery validation plugin. ...

How do I apply a CSS class to html.ActionLink in ASP.NET MVC?

I'm building an ASP.NET MVC application, using VB.NET and I'm trying to apply a css class to a Html.ActionLink using the code: <%=Html.ActionLink("Home", "Index", "Home", new {@class = "tab" })%> But when I run the code I receive the below error: Compiler Error Message: BC30988: Type or 'With' expected. I'm new to MVC and really hav...

ASP.NET MVC - Determine Client's Computer Name

I am building an intranet site that will display different lists based on the computer name because different computers are in different areas, is there a way (within a controller or model) to determine the client's computer name? I have tried system.environment.machinename but that only returns the name of the server, any other ideas? ...

If an errormessage displays a linenumber, does this mean the assembly is build in debug mode?

I have a web that I build with WebDeploymentProject. I thought I had build it in release mode, but now an errrormessage displays a linenumber. I have deployed a pdb file to the server. Can an assembly build in release mode display linenumbers if the pdb is present? Is there any way to tell if an assembly is build in debug mode or releas...

Am I doing this wrong or do I need to ask my hosting service to change permissions?

Hello SO: I am attempting to upload files to my server using ASP.NET MVC. Here is the code that handles the upload request: foreach (string file in Request.Files) { var hpf = Request.Files[file]; if (hpf.ContentLength == 0) { continue; } var savedFileName = Path.Combine(@"~/uploads", Path.GetFileName(hpf.Fil...

How to debug javascript in asp .net MVC?

I am using Visual Web Developer 2008.I have debug my javascript at localhost by adding a breakpoint/debugger in js file.It works perfectly in IE8 before. This nice debug function is broken, after I try a developer tools(Press F12 in IE8). ...

MVC Catch All route not working

My first route: // Should work for /Admin, /Admin/Index, /Admin/listArticles routes.MapRoute( "Admin", // Route name "Admin/{action}", // URL with parameters new { controller = "Admin", action = "Index" } // Parameter defaults ); is not re...