asp.net-mvc

Help migrating asp.net mvc 1 to mvc 2

I just joined a team thats developing a asp.net mvc 1 application. I only have visual studio 2010 installed which comes with mvc 2. I ran the conversion wizard and now the app doesnt seem to compile The error I get is "Cannot apply indexing with [] to an expression of type 'System.Web.Mvc.IValueProvider" i get this error 5 ti...

ASP.NET MVC application fires Session_Start multiple times for a single session

We have an MVC.NET application that encounters fatal errors when it restarts. In our Session_Start event handler, we add the session id to a dictionary. In the Session_End handler, we remove it. Consider the following sequence of requests: GET home.mvc <application restarts> GET main.css GET banner.jpg GET somedata.mvc ... Because o...

asp.net mvc 2.0 Jquery form submit

I am using the following code in my MVC application to login a user. If I get back "1", I redirect user to the dashboard view else login is unsuccessful. $.post($("form").attr("action"), $("form").serialize(), function (data) { if (data == "1") ...

ASP.NET MVC - Controller/Actions or Views or ViewModels first?

I'm familiar with the various bits of functionality of the MVC plugin to create things. For example you can create a controller, write an Action method on it, then use the "create view" function in the context menu to create a view for it. The question is, which is it recommended to do first? I'm thinking I might start myself a method...

Pulling a View from a database rather than a file

Is it possible to load a view from a database rather than from a file on disk? It doesn't necessarily have to be a database, could be any string really. I think I asked this question too soon...I still look forward to any answers but I will definitely do some more research first. Edit So I wrote a quick sample that does what I want - ...

Is MVC2 ASP.Net URLDecoding automatically?

So I was calling the Controller in MVC2 like this and I accessed the classic querystrings just fine. Please notice that the second parameter thing2 is URLEncoded already and again retrieving the URLEncoded querystring and URLDecoding is no problem. My example looks like this... http://mydomain.com/controller?thing1=1544&amp;thing2=som...

ASP.NET MVC - Using HtmlHelpers to create hyperlink image

What's the best practice method for creating images that are hyperlinks in ASP.NET MVC with the html helpers (because I want to supply the controller/action parameters and let Routing create the full URL for me)? This is what I've ended up with but I feel it's a bit rubbish and is the result of ages staring at it not being able to see t...

AllowPartiallyTrustedCallersAttribute error with MVC 2 and .NET 4.0

Assembly 'Foo.BAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may...

Many to Many ASP.NET MVC Binding

If you have scenario of a User that has many Roles and Roles that have many users. Using MVC is there an easy way to bind to the model directly? If your user class has a list of roles and the roles class has a list of users. Thank you. ...

When is it ok to meddle in the page lifecycle an ASP.NET MVC page?

It seems that ASP.NET MVC just runs on top of ASP.NET WebForms. System.Web.Mvc.ViewPage in ASP.NET MVC inherits from System.Web.UI.Page which includes page lifecycle methods like OnRender and friends. I have seen a couple of comments around the web to the effect that you should resist the urge to override these methods AT ALL COSTS!. ...

Can someone explain what is wrong with this Linq-To-Sql code?

See below: Edit.aspx View: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Test.Models.Friend>" %> Edit <h2>Edit</h2> <% using (Html.BeginForm()) {%> <%= Html.ValidationSummary(true) %> <fieldset> <legend>Fields</legend> <div class="edit...

MVC vs ASP Classic

I've been given the task of designing the architecture of a new web based trading system. I see Scott Gu is hot on the task of pushing out MVC releases, but the more i look at them the less difference I see with Classic ASP. Due to the availability of classic ASP programmers, I'm contemplating using this instead of paying top dollar t...

How to re-read files used by ASP.NET MVC web application without apppool recycling?

I'm testing ASP.NET MVC web application and I use Lucene index files. For every test I need to rebuild Lucene index and then to force my web application to re-read these index files. The only way I've found is to recycle application pool, but it's rather slow. Does anyone know a way to re-read files from disc without recycling applicati...

What is the diffrence between MVA and ASP.NET web form?

What is the diffrence between MVA and ASP.NET web form? ...

Optimization for OnAuthentication method using HttpModule.

I made an OnAuthentication method in MVC app. public class MyApplication: HttpApplication { private static IWindsorContainer container; protected void Application_Start() { container = new WindsorContainer(); Container.Register( Component.For<IUserRepository>().ImplementedBy<UserRepository>() ...

I am forced to use Process but I need AppDomain-like security policies. How to do that?

Maxima.exe is a Computer Algebra System built as a native code rather than a managed code. MyService works as a socket server, it will instantiate a new process of Maxima for each browser submitting mathematics expression to Web Server. I cannot use AppDomain here because Maxima is a native code. However I want security policies provi...

Significant advantages of ASP.NET MVC

I'm slowly getting into MVC, but it's still relatively new to me. From what I've discovered by doing a few tutorials, MVC provides an interface for communication between the database and the website and in general allows for better organization of the code. Are there other significant advantages to using an MVC structure? What would be...

MVC Handler for an unknown number of optional parameters.

I am workingon an MVC route that will take an unknown number of parameters on the end of the URL. Something like this: domain.com/category/keyword1/keyword2/.../keywordN Those keywords are values for filters we have to match. The only approach I can think of so far is UGLY... just make an ActionResult that has more parameters than I ...

style problem with data returned from action method

Controller action: public string Index(){ var tmp = (from i in Message.message where i.To == "bognjen" && i.Read == false select i.Read).Count().ToString(); return tmp; } Part of View: <li><a>Inbox <%=Html.Action("Index","MyController")%></a></li> When action Index return string it is not...

How do I turn off browser caching for my entire ASP.NET MVC site?

I'd like to disable browser caching for every page on my site. I know I can do it per action, but I'd like to know if there's a way to do it site-wide. ...