asp.net-mvc

Code generation for views broken when using custom MVC ViewData classes.

I'm by no means lazy, but already 2 days overdue on our current sprint in my first ever MVC project, so I've been using the Add View Wizard to generate strongly typed views, but now that I have started using ViewData classes as view models, the wizard generates fields for ViewDataBase, and not my derived ViewData. I think that the deriv...

Call controller action in current context from, for example, Filter

I've tried to call controller action from filter. But i've discovered that if i want to do that i had to.. var controller = new MyController(); controller.ControllerContext = filterContext.Controller.ControllerContext; controller.<action>(<parameters>); // it's action which accepts only POST, but here it doesn't matter base.OnActionExec...

ASP.net, MVC 2 - Posting viewModel

My problem is that when I submit the form and returning my viewModel of type QuestionViewModel - the Type is null. See code below. My controller: public ActionResult Create() { var viewModel = new QuestionViewModel { Question = question, Type = questionType, Types = surveyDB.Q...

Asp.Net MVC double submit/request breaks SQL connection

Hello all, I am running into a strange problem I don't fully understand. The main symptom is that when I double click a link (that points to a controller action) in my MVC application, my database server connection gets blown, and I get the error : Execution of the command requires an open and available connection. The connection's cur...

Problem with accessible in DotNetOpenauth?

I working on MVC project and use DotNetOpenAuth to connect with twitter, Once i declare private static InMemoryTokenManager _tokenManager = new InMemoryTokenManager("Twitter Consumer key", "Twitter Consumer secret"); private InMemoryTokenManager TokenManager { get { return _tokenManager; } ...

Does Site.Master NEED to have a "TitleContent" ContentPlaceHolder? Can I get rid of it?

We use a wrapper that is delivered to us by our client, into which we inject all of our content. Our master page currently looks like this: <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title> <%= (string)ViewData["WrapperTop"] %> // wrapper is split by a <ContentWell /> tag <div> <asp:ContentPlaceHo...

Null Values returned to Controller for Edit action.

I have the following actions in my controller. The first (top) Edit works fine and serves the correct values. However, in the second one, i.e. the 'return' Edit, every property of model is at default value, i.e. null for ref types and zero for value types. I have examined the HTTP post data and it has all the properties correctly name...

Passing exceptions across threads in an MVC application

I need to call a few webservices while constructing an MVC page, so I'm threading the work via the threadpool, and using ManualResetEvents to to determine when I have my results. If one of the threads throws an exception though, it'll crash the app. I have exception handling set up via a Filter, but I need to get the exception back t...

asp.net mvc integration test

Hi Im doing TDD for an asp.net mvc project, I need to be able to do end to end testing fie sending a request to the controller action all the way to the repository. I have tried using http://blog.stevensanderson.com/2009/06/11/integration-testing-your-aspnet-mvc-application/ but unfortunately I cant get this to run and Im running out o...

I need a language dictionary

I need to add dictionary facilities to an Asp.net MVC app. Does anyone know a library that I could use? Where can I get word definitions from? Any help is appreciated. ...

Getting error in uploading files

Hi All I am getting following error while uploading file in asp.net. "Length = 'stream.Length' threw an exception of type 'System.NotSupportedException'" I have already configured httpRuntime in config as follow:- <httpRuntime maxRequestLength="2097151" executionTimeout="7200" /> This error occurred usually when i tried to upload f...

jQuery Validator 'form' is null or not an object from $(document).ready

This question is in relation to A Previous Question, however, since it was a completely different I decided to start a new question. In my code, i have a $(document).ready that calls a function addChild. It works just fine, unless I call the function more then once. If I call 2+ times in the $(document).ready, it will give the error: ...

Is this safe to store in custom IIdentity

I have created a custom Iidentity object to store specific user settings for logged in users. I was wondering is it safe to store sensitive data like userid's or other id's in the object? Is there any security risk to doing so? Also, how much is too much to store in the object? Thanks ...

ASP.NET MVC Authorization with jQuery & AJAX posting in IE

I'm not sure how to post this question without including half of my sites code, but here goes. I have a site with a Subcontract Form, a Company Form, and a Contact Form. From the subcontract form, you can create a new company and/or a new contact via buttons which open jQuery dialogs and post the company or contact information. From t...

Why does a trailing %20 (valid data in this case) kill asp.net mvc routing

Take the following controller action public ActionResult NextBySURNAME(int id, string data) { //code to process the data and edit the id accoringly not written yet return RedirectToAction("Edit", new { id = id }); } if I call it with /Mycontroller/NextBySURNAME/12/Smith%20Simon then it works fine (in this...

CSS include with MVC

So I know there are various ways of doing, however I'd like to know the "proper" way of including a specific CSS dynamically based on the page I am on. I could include all of them within the site master, however I'm wondering if I could simply include them ONLY when I need it, by either evaluating URL or passing a value through the cont...

Stream file using ASP.NET MVC FileContentResult in a browser with a name?

Is there a way to stream a file using ASP.NET MVC FileContentResult within the browser with a specific name? I have noticed that you can either have a FileDialog (Open/Save) or you can stream the file in a browser window, but then it will use the ActionName when you try to save the file. I have the following scenario: byte[] contents ...

Where to put ParseUrl() or similar function that works against a datastore, in ASP.NET MVC?

If you were to code a function/method that would, for entered string or slug (for instance in Create or Edit view), go into datastore and check whether that string or slug exists and in this case create a link to it, where would you put it? For instance, we have a "Link" textbox on our Create or Edit form. I have a jQuery autocomplete w...

ASP.NET MVC BaseController

I use a BaseController to wire up my service layer. All other controllers inherit this controller. Now I'm embarking on building an MVC2 project template. I would like controllers to inherit this by default, not just the ": Controller", but have no idea how to approach this. ...

How easy is it to port ASP.NET MVC to Silverlight application and vice versa?

I was thinking of writing a client application in ASP.NET MVC first to make it available over the net to everyone. In the near future I'd like to port it to Windows Phone 7 using Silverlight. How much of the code can I re-use from ASP.NET? Would I have to completely rewrite it? Thanks in advance! ...