asp.net-mvc-2

Handling FileContentResult when file is not found

爷,独闯天下 提交于 2019-11-29 18:28:41
问题 I have a controller action that downloads a file from an azure blob based on the container reference name (i.e. full path name of the file in the blob). The code looks something like this: public FileContentResult GetDocument(String pathName) { try { Byte[] buffer = BlobStorage.DownloadFile(pathName); FileContentResult result = new FileContentResult(buffer, "PDF"); String[] folders = pathName.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); // get the last one as actual

Problems updating w/ EF4 repo & MVC2 - can't update many-to-many graph

左心房为你撑大大i 提交于 2019-11-29 17:52:10
I can't seem to successfully update a many-to-many graph in MVC2 using EF4. I figured the simplest thing to do would be to Clear() the entire graph, call SaveChanges(), then rebuild the graph calling SaveChanges() again at the end, but it's not working. All my other properties ARE working, however. First, my Action Methods: public ActionResult EditReview(int id) { var game = _gameRepository.GetGame(id); var genres = _gameRepository.AllGenres(); var platforms = _gameRepository.AllPlatforms(); var model = new AdminGameViewModel { GameData = game, AllGenres = genres, AllPlatforms = platforms };

Facing issue while trying to Comment on a Post Facebook in MVC3

烂漫一生 提交于 2019-11-29 17:35:40
I am trying to send the reply to a Facebook Post. Below is my action method public ActionResult GetMyDetails() { var fb = new Facebook.FacebookClient("appId", "appSecret"); dynamic obj = fb.Post( "https://facebook.com/ PostID/ comments/?message=ws&access_token=" + fb.AccessToken ); } Query - I basically want to know, why A comment on Post using the above code is not working ? 来源: https://stackoverflow.com/questions/15740168/facing-issue-while-trying-to-comment-on-a-post-facebook-in-mvc3

Display empty textbox using Html.TextBoxFor on a not-null property in an EF entity

↘锁芯ラ 提交于 2019-11-29 17:16:21
问题 I am using Entity Framework (v4) entities. I have an entity called Car with a Year property of type integer. The Year property does not allow NULL. I have the following in my Create view: <%= Html.TextBoxFor(model => model.Year) %> I am required to return a new Car object (due to other requirements) in my HttpGet Create action in the CarController. Currently, a zero is displayed in the Year textbox because the Year property does not allow NULL. I would like to display an empty textbox in the

Can a Web User Control (.ascx) use a CSS file for styling?

感情迁移 提交于 2019-11-29 16:23:22
Here's the source of a blank .acsx file I created called LogOnBox. <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LogOnBox.ascx.cs" Inherits="ECommerce.Views.Shared.LogOnBox" %> I want to drag some labels, and textboxes etc and give them style using a CSS file. How can I associate a CSS to an acsx file? The CSS is associated to the page, and not the control specifically. But you can use the CSS in the control when the page has referenced it. Just reference the css file in the header of the page containing the user control. In my cases i would like to embed css and js file into

POST Ajax call results in not found using jqGrid and ASP.NET MVC 2 on IIS6

戏子无情 提交于 2019-11-29 16:20:20
This is puzzling me. I deployed an MVC 2 application to IIS6 and everything works fine except for my jqGrid calls to get data. All is well on my development machine, but here are the two URLs I'm working with Local dev web server: POST http://localhost:port/Ctrl.mvc/JsonMethod IIS6 (notice https - not sure if that matters) POST https://www.domain.com/AppName/Ctrl.mvc/JsonMethod The latter URL results in a HTTP 404, which is really confusing as all works well on my local machine. The JsonMethod is properly declared with [AcceptVerbs(HttpVerbs.Post)] Let me know if any more info is needed - I

Why am I getting App_GlobalResources assembly generated? (Error = CS0433)

余生颓废 提交于 2019-11-29 16:15:06
I'm working on a ASP.NET MVC2 project, for which I have configured the localisation as follows ... I have a separate Resources assembly, containing all my resx files. The settings for each resx file are... Build Action = Embedded Resource Copy to Output Directory = Do not copy Custom Tool = PublicResXFileCodeGenerator Custom Tool Namespace = Resources I have a tool which exports the strings from a database into the resx files and calls the resgen.exe tool to recreate the designer.cs file. This all worked great, even when I changed the language settings of my browser and refreshed the page. It

Guidance on a better way to retain filtering options when using ASP.NET MVC 2

随声附和 提交于 2019-11-29 15:54:38
I have an ASP.NET MVC 2 application which in part allows a user to filter data and view that data in a JQGrid. Currently this consists of a controller which initialises my filter model and configures how I wish my grid to be displayed. This information is used by a view and a partial view to display the filter and the grid shell. I use an editor template to display my filter. The JQGrid makes use of a JsonResult controller action (GET) to retrieve the results of the filter (with the addition of the paging offered by the grid - only a single page of data is returned by the GET request. The Uri

ASP.Net MVC 2 Model Validation Regex Validator fails

馋奶兔 提交于 2019-11-29 15:37:39
I have following property in my Model Metadata class: [Required(ErrorMessage = "Spent On is required")] [RegularExpression(@"[0-1][0-9]/[0-3][0-9]/20[12][0-9]", ErrorMessage = "Please enter date in mm/dd/yyyy format")] [DataType(DataType.Date)] [DisplayName("Spent On")] public DateTime SpentOn { get; set; } But whenever I call ModelState.IsValid it always returns false because regex is not validating. I have matched the entered date (08/29/2010) against new regex using same pattern and it matches perfectly. What am I doing wrong? Darin Dimitrov That's because regex applies to strings and not

Migrating legacy ASP.NET to MVC 2 (RC): HttpApplication events not firing, User principal is null

被刻印的时光 ゝ 提交于 2019-11-29 15:23:59
Problem I am trying to take an existing ASP.NET web application and manually migrate it over to use MVC 2 (I am currently running the RC). I followed several steps (I'll list in a moment) and seemed to have it working, but then I noticed I can't set the AuthorizeAttribute because User is null on the controller. Then I noticed that when I navigate to an action, none of the HttpApplication's usual lifecycle events are being raised (such as BeginRequest, etc.). I figure that's probably related to why User principal is null. The web host is a local IIS7 instance (on my Vista workstation). I