asp.net-mvc

Read in a html page within asp.net mvc

i am porting over a website from asp. i have one page that i can't figure out how to migrate it. The page is dynamic in the sense that it reads in other html pages and sticks the content into the main "container" page. In the middle of the asp page it has sections like below <% Dim fso1, f11, ts1, s1 Const ForReading1 = 1 Set fso...

Storing more information using FormsAuthentication.SetAuthCookie

I am using aspx and c# for a setting a authentication cookie for a login. FormsAuthentication.SetAuthCookie(UserName, True) I want to store more information in the same cookie. Can I add values to this authentication cookie or do I have to use a second http cookie? Basically I'm looking for away to store the User's Id so I may be able ...

Does ASP.NET MVC provide any way to implement UpdateProgress WebForms control analog?

Does ASP.NET MVC provide any way to implement UpdateProgress WebForms control analog? Can anyone explain me how to achieve such client-side functionality with MVC? ...

asp.net mvc page cant find reference

i created a new class called HTMLRenderer and i am calling it from my aspx view code namespace Golf.Content { public static class HtmlRenderer { public static void RenderHtmlPage(HtmlHelper helper_, string path_) { var reader = new StreamReader(path_); var contents = reader.ReadTo...

asp.net MVC Read from a http URL

i am trying to use this code: <%= File.ReadAllText(Server.MapPath("Members/newsletters/welcome.html"))%> which works great but now the welcome.html file has moved onto another server so i need to read it from an external URL . any suggestions? ...

ASP.NET MVC Html Helpers - is Response.Write needed?

When using the Html helpers for ASP.NET MVC I need to wrap them in a Response.Write else they don't appear. However the samples (1&2 for example) I find online for ASP.NET MVC don't seem to do that. Did something change somewhere or am I doing something wrong? From the samples I find it should be like this: <div class="row"> <% Htm...

My ISP does not support ASP.NET MVC. Can I still use some of it anyway?

My ISP doesn't have ASP.NET MVC installed on their servers yet, although they do have .NET Framework 3.5 SP1 so they do have the new routing engine. It occurs to me that, if I create a model using Linq to SQL, it's possible to expose parts of the model as properties in the code behind. I could then render them in the web page (my "view...

MVC, Jquery, and Ajax to display object based on dropdown

I'm trying to design a view to accept donations, sell memberships, or sell tickets to events. I have a dropdown list that displays "Make a donation", "Purchase membership", and the subsequent options are populated from the IList<Event> Model passed from the controller. I use javascript to determine which panel (membership, donation, or...

How to implement authorization checks in ASP.NET MVC based on Session data?

This will be my first ASP.NET MVC application with forms authentication so I am trying to make sure I don't miss anything. The scenario is this: Public / Secured Areas. Within the private area it is even further limited to specific areas / user. These 'Areas' are defined by customizations to the base area that is customized per user gro...

Shared Code Between Multiple Asp.Net projects

What's the best practice to share the bin folder and dlls and other resource files (like css) between multiple web applications on the same server? I've already separated out the common code into their own assemblies, but I'm wondering about deployment, etc. I basically want to have all the common files located in ONE location on the w...

Storing images in a Sql Server 2008 database using Filegroups/Filestreams

Has anyone had an experience storing user uploaded images in a MSSQL 2008 Database using Filegroups and Filestreams? I read a few articles that seemed to say they are a good idea because you get all the advantages of storing images on disk and in the db. For example I have implemented this for my current project but it seems like I'm d...

how to add html.Validation().FormValidation() to Html.BeginForm

If I have this code: <% using (Html.BeginForm("CreateItem", "Item", FormMethod.Post, new { enctype = "multipart/form-data" })) { %> <label for="ItemImage">Item Image:</label> Please use JPEG file format only.<br /> <input type="file" name="file" /> <%= Html.ValidationMessage("ItemImage", "*") %> <% } %> And I want to ...

ASP.NET MVC Programatically Get a List of Controllers

In ASP.NET MVC is there a way to enumerate the controllers through code and get their name? example: AccountController HomeController PersonController would give me a list such as: Account, Home, Person Thanks! ...

unlimited for maxJsonLength

Can i give unlimited length for maxJsonLength? I am using the autocomplete feature of jquery. When i try to retrieve the list of more then 17000 records(each wont have more than 10 char length), its exceeding the length and throws the error: Exception information: Exception type: InvalidOperationException Exception m...

ASP.NET MVC, HandleError Attribute, and Tracing: Bug?

I seem to be encountering some funky behaviour when tracing is enabled in an ASP.NET MVC application: Whenever tracing is enabled, the HandleError attribute fails. I've reproduced this on the vanilla ASP.NET MVC app, and was wondering whether anyone has experienced anything similar. Steps to Reproduce Step 1 Create a new ASP.NET MVC...

ascx MVC controller need to know the calling Controller

I have an MVC View User Control and from with Controller I would like to find out what the name of the controller that the MVC View User Control has been called from. Hope that makes sense? ...

ASP.NET MVC Model Binders. Call a controller with an array of objects parameter.

I would like to have the following signature of a MVC controller. public ActionResult Create(Persons[] p) { } Is it possible to have something like this? EDIT: Let's say I would like to obtain an array of person objects by submitting a list of names separated by a special symbol. For example I submit a form <form> <input name="...

Set a ServerVariable value when mocking HttpRequest using Moq?

I am mocking an HttpRequest object using Moq for unit testing in ASP.NET MVC. I need to set one of the ServerVariables (LOGON_USER) in the request. Is this possible? I have tried using the following method, but I get an exception because the ServerVariables collection is non-overridable. request.SetupGet(req => req.ServerVariables["...

asp.net-mvc where do i put my own code

is there any particular directory that i should put my code into in an asp.net mvc project i have some extentions to the HtmlHelper class. Right now i have it sitting in the Content folder. is this correct? is there a better soluiton? ...

How to do If statement in Linq Query

I currently have a list that contains the following CountryCode (string) CountryStr (string) RegionStr (string) RegionID (int) AreaStr (string) AreaID (int) This is a flattened set of linked data (so basically the results of a joined search that ive stored) The MVC route will only pass one string which I then need to m...