asp.net-mvc

Difficulties to send File to view using FileContentResult action method.

Hello, I need to display in image on the view this way <img src = <% = Url.Action("GetImage", "Home", new { productID })%> This is the action which's supposed to supply data public FileContentResult GetImage(int ID) { var img = db.Images.Where(p => p.ID == ID).First(); return File(img.ImageData, img.ImageMimeType); } This exam...

redirect to a actionresult in mvc but not want to go to page by return view()

i want a facility that if user login then goes to home/index i not want to use return view('~/views/home/index'); i want to redirect it to a actionresult index of home controller of my web-application(in asp.net mvc) how i can do this without return view(); i want to redirect him. public actionresult login if(userlogin) { // go...

How do I debug a situation with an MVC application that doesn't appear to throw any exceptions

We've recently developed an internal web application for our intranet on top Microsoft's MVC Framework (v2). This seems to work wonderfully, but after some as yet unknown events, we're seeing a situation where database queries appear to yield no results, whilst no exceptions are caught, which has stumped me somewhat. Republishing the ap...

Transaction exception problem - s#arp architecture

Hi, I am deleting things like this: [Transaction] [AcceptVerbs(HttpVerbs.Post)] public RedirectToRouteResult DeleteQualitativeGlobalFeatureValue(string Id) { try { BlaService.DeleteBla(Id); } catch (Exception e) { ModelSt...

Should ASP.Net MVC apps be more link-driven?

Strange question, I know, but one thing I seem to be feeling with ASP.Net MVC is that it's smoother and more logical to try and avoid form-submissions unless totally necessary (especially if you have more than 1 on a single view). As an example, you have a list of items and you can sort the items, to me it seems to be a more 'fitting' i...

ASP.NET MVC Form with multiple dropdowns and checkboxes group

I am lost with the submission of listbox with multiple itmes selected and with group of checkboxes. If that was a WebForm project it wouldn't be a problem for me. What are the best practices and maybe some code samples that show proper submission of form in ASP.NET MVC2 that contains group of checkboxes and listbox with mutiple selecte...

Render partial in an extension method fails

I'm creating a tabcontainer that shows information from partials. The code that i've created is as follows: //Entering extension method, m_helper is of type HtmlHelper foreach (var tab in m_tabList) { sb.AppendLine("<div class='tabContent'>"); m_helper.RenderPartial(tab.PartialName); sb.AppendLine("</div>"); } //Returni...

How to display a picture using data from ViewData.Model [as opposed taking data from a remote location using, for instance, Url.Action]

Hello, I'm doing kind of wizard application that captures information on Contacts. So, before saving to DB, all data collected during the process are kept in memory as model's properties (using serialization/deserialization). Data collected includes the uploaded picture of the contact. The last page is called "preview" where I display a...

Having a class and ID together in an HTMLHelper method. ie. Text

I saw this implemented somewhere but basically below I'm using the textbox HTMLHelper to draw a textbox with the id myID and default text 'text_goes_here'. I want to also add a class to thiis helper, i saw somewhere it implemented with new {@class =''} as a third parameter creating an object but im not sure exactly how its wrote <%= Ht...

Is there any reason I should NOT auto-trim html form parameters?

Hi, I just noticed to my surprise that whitespace at the start or end of form parameters is not automatically removed in ASP.NET MVC 2 (browser: Firefox). I always assumed this would be the case, simply because I could not see a scenario where I would NOT want trimming to happen by default. This can be fixed very easily by implement...

View issue - multiple 'delete forms'

Hi I have a really strange ‘bug’. I use this in my view: <% foreach (var QualitativeGlobalFeatureValue in Model.PossibleValues) { %> <% using (Html.BeginForm("DeleteQualitativeGlobalFeatureValue", "Features", FormMethod.Post, new { @class = "deleteForm" })) ...

FilePathResult or custom Action Result?

To send pdf files (or any other file type) to the browser, I've seen examples that use the FileResult class or a custom Action Result. Is there an advantage of using one over the other? Thanks ...

asp.net trust level error

I deployed an asp.net mvc application and everything worked except for my Gallery page that streams pictures using flickr api. I get the following error. Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact ...

asp.net mvc model item passed in to dictionary is of type List

I have a asp.net mvc view which is strongly typed view and i have a controller which returns the ilist user based on the id provided. I am getting the following above error: The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[Data.User]', but this dictionary requires a model item of type 'Data.User'...

Is it possible to retain custom attributes in a class instance after deserialization?

I'm trying to build a custom HTML helper for MVC.NET that would allow me to render object entities (Model Objects) as HTML forms. So I decided to do it using custom attributes such as html input type, readonly flag, css classes, etc. Similar in a way to LINQ Mapping attributes that set database related bindings for Table and Column. So I...

Fluent Nhibernate System.ApplicationException : For property ‘Id’ expected ‘1’ of type ‘System.Int32’ but got ‘2’ of type ‘System.Int32’

Hi I am writing unit tests for fluent Nhibernate, when I run the test in isloation it passes, but when I run multiple tests. or run the test more than once it starts failing with the message below System.ApplicationException : For property 'Id' expected '1' of type 'System.Int32' but got '2' of type 'System.Int32' [TextFixture] public v...

Interface arguments in ASP.NET MVC

I'm in the process of developing an ASP.NET MVC project, and after several weeks of research, I have a pretty good framework in place using StructureMap to register my dependencies at bootstrap time, create my controllers with the correct implementations, a custom model binder for passing data to my controller, etc. After thinking about...

ASP.NET MVC Strongly Typed View With DropDownList

Long story short, I'm trying to add a few extra items to ViewData to make my life easier, and its an edge case that doesn't really justify its own model just for this one case. Keep reading for more specific details. So I have a strongly typed edit view for one of my objects, everything works great until I try to put a dropdownlist on t...

how to create a asp.net mvc form helper that takes virtual directory into consideration?

how to create a asp.net mvc form helper that takes virtual directory into consideration? In testing our dev server has: http://devserver1/some_virt_directory/ production is: http://www.example.com I need the form post url to reflect if we have a virtual directory or not, is this possible? ...

ASP.NET MVC Updatable List View

I can't find anyone doing this, and I'm trying to get my head around the best way to tackle this issue. I'd like to take the standard "List View" view in an ASP.NET MVC application, and convert all of the "Labels" to "TextBoxes" and then save any changes made to each record. The end result would function very similar to the List View i...