Hi. I'm working with MVC ASP.NET 3.5 SP1 on VS2008.
I'm looking for a way to abstract this three methods I have in my Users repository.
public User GetUser(Log log)
{
return db.Users.FirstOrDefault(u => u.Logs.Any(l => l.id.Equals(log.id)));
}
public User GetUser(Product product)
{
return db.Users.FirstOrDefault(u => u.Products.Any...
I have a number of documents (in an MVC app) that exist solely to be called by:
<% Html.RenderPartial("showLoginStatus"); %>
While editing the file in VS (08) the CSS class selectors used within this page all toss 'class not defined' warnings since the stylesheet isn't referenced in this file but in the 'parent'.
The page renders cor...
I have a route like this in my global.asax.cs:
routes.MapRoute(
"NewsArticles",
"News/{page}",
new { controller = "News", action = "Index", archive = false }
);
How can I restrict access to this route so that it's only encountered if the user uses an integer?
...
I recently used ASP.Net MVC with DataAnnotations and was thinking of using the same approach for a Forms project but I'm not sure how to go about it.
I have set my attributes but they do not seem to get checked when I click Save.
UPDATE: I have used Steve Sanderson's approach which will check for attributes on my class and return a col...
I wanted to consume a WCF service with a silverlight application and a asp.net mvc application, and I'm having difficulties to configure the service to support both requests.
these are my endpoints for the WCF config file.
<service behaviorConfiguration="behaviorAction" name="Uniarchitecture.ProdutoService.ServiceImplementations.Prod...
I'm getting a strange error on my webserver for seemingly every file but the .aspx files.
Here is an example. Just replace '/robots.txt' with any .jpg name or .gif or whatever and you'll get the idea:
The controller for path '/robots.txt'
was not found or does not implement
IController.
I'm sure it's something to do with how I...
I have an ASP.NET MVC application. I need to cache some actions (pages) however for some pages I need do such only for non authenticated users.
I've tried to user VaryByCustom="user" with following GetVaryByCustomString implementation.
public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (custom == "u...
Hi,
Im using scott hanselmans file upload code:
public ActionResult UploadFiles()
{
var r = new List();
foreach (string file in Request.Files)
{
HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase;
if (hpf.ContentLength == 0)
continue;
string savedFileName = Path.Combine(
AppDo...
This is wierd.
First, I'm building a site based on someone else's framework (Piers Lawson: Creating a RESTful Web Service using MVC ), so I'm not entirely sure what's going on under the covers. But when I run it in VS 2010 by pressing F5, it brings up the Home page, and THEN traps an error in Application_Error. The error is "File does...
I'm using ASP.NET MVC 2 with DataAnnotation attributes sprinkled on properties like so:
public class LogOnViewModel
{
[Required]
public string UserName { get; set; }
[Required]
public string Password { get; set; }
[Required]
public string Domain { get; set; }
}
I have a unit test which checks that the curre...
Hi,
Given a Controller name, and a Action name - "AdminController", "Index" for example, is it possible for me to get back all the possible Areas.
Does that make any sense to anyone?
Cheer,
ETFairfax.
...
I am using MVC.
I have a view model which contains a Business object.
I need to post this Business Object back to a controller action using AJAX.
For now, I am using Url.Action function to create my request Url for AJAX and pass the Business Object id as a request parameter to the action. I then have to retrieve the object from the dat...
I've created an extension method:
namespace MyComp.Web.MVC.Html
{
public static class LinkExtensions
{
public static MvcHtmlString ActionImageLink(this HtmlHelper htmlHelper, string linkText, string imageSource, string actionName)
{
...
}
}
}
I've referenced the assembly from my mvc app,...
I have a simple web-site. Almost every action takes int toonId as an argument (toonId does not equate to the user: one user can own multiple toons).
At the moment I provide that value to every view from controller, and every link and submit button sends this value back to the controller.
This works. I am just looking for an easier way to...
Is there any advantage to leaving the Scripts folder where it is in the default ASP.NET MVC Project structure.
In my mind it makes more sense to create subfolders for scripts, css files, and images under the Content folder.
Any downside to doing this?
...
I want users to be able to export data as an XML file. Of course I want them to be able to later on import that same XML file however they always could change it or it could be a different XML file.
So I want to validate the XML file to check if it is in the format that I expect. So I guess I would need something like a schema to check ...
I'm trying to get a good idea on how to modify certain parts of the page based on what page I'm looking at. I can set certain elements with the page's controller but I'm thinking more about the global navigation menu's (currently being rendered with a RenderAction in the application's MasterPage) active states.
Like if I have some navi...
How would I know which version of MVC (i.e 2.beta, 2.Release candidate) is installed on my machine..
...
What is the difference when retrieving username for the view?
<%= Page.User.Identity.Name %>
or
<%= Membership.GetUser().UserName %>
...
I have the strangest problem that I simply cannot solve by myself.
I have this ASP.NET MVC 1 application that works flawelessly on my local development machine, using IIS5.
I made the appropriate changes to get MVC to work on IIS5 by adding a route for .mvc controllers and an aspnet_isapi.dll filter as documented in http://haacked.com/...