asp.net-mvc

Is there a way to process an MVC view (aspx file) from a non-web application?

I have a background service running which sends out emails to users of my website. I would like to write the email templates as MVC views, to keep things consistent (so that the same model can be used to send out an email as to display a web page). Unfortunately, when I try to do a LoadControl (which simply patches through to BuildMana...

Where to put business rules for querying when using NHibernate?

Still new to NHibernate. I'm using NHibernate 2.1.2 and the Linq provider. I am wondering where I should put my business rule logic. For example, I have an entity called Service with DateTime property. In my web app, I only ever want to display/work with services whose DataTime is less than 4 weeks away. Where should I put that rule? I...

Using the Description Metadata Attribute in ASP.NET MVC

I am working on a VB.NET project which is using ASP.NET MVC 2. I am taking advantage of the ability to add validation and other attributes to the metadata in my model. For example, I have added attributes such as <DisplayName("Full Name")> to the properties in my model and am rendering these using the Html.LabelFor () extension method....

Part of ASP.NET MVC application data save not being applied

Hello SO: I am writing an MVC application, and I wanted to do some extra formatting so the phone numbers all are stored the same. To accomplish this I made a simple external function to strip all non-numeric characters and return the formatted string: public static string FormatPhone(string phone) { string[] temp = { "", "", "" };...

Suggested approach to generate pages based on attributes on properties in model in ASP.Net MVC!

Hi, We need to generate forms for Create/Display/Edit on our website. The requirement is that these need to be metadata driven. We will have properties on our Model attributed with the type of control to generate for that property. [RenderAs("DatePicker", Order = 1)] public DateTime DateOfBirth{get; set;} The idea is to have templa...

Why is this code sending 0kb files to the browser?

here is the call... return new FileUriResult("application/octet-stream", a.AssetPath, null); [note that I set content length to null because I don't know it (file is on another server)] a.AssetPath is: "http://http.cdnlayer.com/account name/folder/folder/folder/asset.mp3" (fake URL for this example but in my implementation I can bro...

Html.RenderAction using AJAX

Is it possible to use HTMl.RenderAction using ajax to provide the parameter? I have a controller action like this [ChildActionOnly] Public ActionResult EmployeeData(string id) { Employee employee = new Employee(); //do work to get data Return PartialView(employee); } The partial view is just a small table with some empl...

ASP.NET MVC & Entity Framework: How to render a custom Model in a View ?

Hi, I have two tables Category 1..* Advertisement. I want to get the advertisements Count for each category. To do so, I use that query: var catList = (from c in DB.Category.Include("Advertisement") select new { c.Name, c.Advertisement.Count } ).ToList(); How to access the e.g the first element's p...

Creating an external link in ASP.NET MVC 2 from model properties

I'm trying to build a link to an external website using some properties of my model class in my view page, e.g. I want it to render as something like - < a href="http://twitter.com/home?status=Currently reading http://www.mywebsite.com/post-id">Twitter < /a> where post-id would be pulled from the model (I'm using a strongly typed view ...

Html.Encode does not work atleast not as i think it should

In asp.net mvc 2 view i am trying to render something if true. In code below i am trying to use Html.Encode(x) to render value into page but it does render nothing. What is wrong with if statement with html.encode? Works <%if (!ViewData.ContainsKey("DisplayQtyPrice")) {%> <%: entry.Amount %> <%}%> Does not work <%if (!ViewD...

Using AJAX to load an MVC user control inside of a jquery tab inside of a jquery dialog (C# Inside)

I have an index page for listing products. From this page I would like to be able to open a dialog with the following tabs. Edit/Create Product, Product Images, and a tab for Brands. The brands tab isn't specific to the product being edited/created, and doesn't require being passed an ID. I have everything broken up into the following pa...

HttpContext.Current.User is null in ControllerBase(asp.net mvc)

I have a ControllerBase class in an ASP.NET MVC Application. The other controllers inherit from ControllerBase. I want to access HttpContext.User.Identity.Name, but HttpContext is null. What's the matter? public ControllerBase() { var dataManager=new DataManager(); if (HttpContext.User.Identity.IsAuthent...

Setting optimum http caching headers and server params in ASP.Net MVC and IIS 7.5

I have an ASP.Net site (happens to be MVC, but that's not relevant here) with a few pages I'd like cached really well. Specifically I'd like to achieve: output cached on the server for 2 hours. if the file content on the server changes, that output cache should be flushed for that page cached in the browser for 10 minutes (i.e. don't...

Is there any kind of idiots guide to deploying your ASP.NET MVC website in one click?

Hello. I'm about to begin building a website using the ASP.NET MVC framework and I'm trying to find a good solution to 1)Source Control Management and 2)Deployment. For the SCM, I'm probably going to use SourceGear since it integrates into Visual Studio nicely, but for deployment, I don't even know where to start. Up until know, most ...

Append or set value on page after post of the page from MVC application?

how do i append or get variable to server side function from MVC application after HttpVerbs.Post? in client side code: <input type="hidden" id="hidPopUpMsg" name="hidPopUpMsg" class="hidPopUpMsg" value="" /> <% Using Html.BeginForm("SelectedProvider", "Scheduling", New With {item.PRVNO, .PhoneNumber = item.PPHON, .FaxNumber = item.PP...

mvc.net how to populate dropdownlist with enum values

I have an enum for one of the properties of my view-model. I want to display a drop-down list that contains all the values of the enum. I can get this to work with the following code. What I'm wondering is whether there is a simple way to convert from an enum to an IEnumerable? I can do it manually as in the following example, but wh...

JQuery Validate using addClassRules: What am I missing?

I've put together a snippet of code in ASP.NET MVC in which I'm trying to use the addClassRules methods of jQuery's validator. From what I can tell I'm taking this straight of the examples on http://docs.jquery.com/Plugins/Validation/Reference But the page is just submitted it doesn't show any errors. I would like to use the "addClas...

Post image file to RESTful Web Service

Hi Everyone, I'm trying to send an image file to a web service. here's my code: ConnectionFactory connFact = new ConnectionFactory(); ConnectionDescriptor connDesc; //String value = new String(data); String value= Base64OutputStream.encodeAsString(data, 0, data.length, false, false); value = "imgDa...

Adding/updating child and parent record same time

Can someone please show me the easiest way to create/update a parent and child record at the same time (like customer with multiple addresses) with least or no code as possible? Both Web Forms and in MVC. ...

Asp.net MVC2 ModelBindingContext.ModelName empty

I'm not even quite sure where to start explaining this problem. I've been working on this for about the past 10 hours without a clue as to what the root cause is. If any additional details are needed, I'd be happy to provide. I'm just guessing at what is relevant at this point. I have an MVC2 site with routes set up by by Steve Hodgkiss...