asp.net-4.5

SignalR Adding/Removing Connections from a dictionary and finding Group values from dictionary

北慕城南 提交于 2019-12-23 05:22:48
问题 I have Organizations that login to an asp.net website and when each member logs in I add their ConnectionId and OrganizationId to a static ConcurrentDictionary named OrganizationMembers in a SignalR Hub OnConnected override. I do this so I can send data to a page callback function that contains data relative only to that Organization (SignalR Group). The OrganizationId will represent the SignalR Group that I send data to. Also in the OnConnnected method, I add the OrganizationId and

Using Task.Run in a syncronous asp.net controller

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 05:13:21
问题 Is there an efficient way to download a file and save it on disk in a "background" way without blocking the current execution of an action in a mvc controller? Currently I have the following example code working: public ActionResult Index() { InitiateDownload(); var model = GetModel(); return View(model); } private void InitiateDownload() { Task.Run(() => DownloadAndSaveFileAsync()).ConfigureAwait(false); } private async Task DownloadAndSaveFileAsync() { var response = await GetResponse();

MVC Web API, get sub items

浪尽此生 提交于 2019-12-22 17:39:06
问题 I have a database with two tables. Countries and Cities where each city has a relation to a spesific country. In my ASP.Net Web API I can get a list of countries by a GET request to http://example.com/api/countries to run the CountriesController. And I can get details about a country by http://example.com/api/countries/1. If I want a list of all cities for a country the REST query URL should be http://example.com/api/countries/1/cities? And details for a City http://example.com/api/countries

UseLegacyPathHandling is not loaded properly from app.config runtime element

柔情痞子 提交于 2019-12-20 03:21:58
问题 I'm trying to use the new long path support at my app. In order to use it, without forcing clients to have the newest .net 4.6.2 version instelled on their machines, one should only add those elements to his app.config (see the link for more info https://blogs.msdn.microsoft.com/dotnet/2016/08/02/announcing-net-framework-4-6-2/) : <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/> </startup> <runtime> <AppContextSwitchOverrides value="Switch.System.IO

Check box inside repeater , How to get command name value in the check changed function

丶灬走出姿态 提交于 2019-12-19 21:53:53
问题 HI i have above html tag in my asp.net listview item template , <td> <asp:CheckBox runat="server" ID="chkStudentStatus" Text='<%# GetStatusString(Eval("StudentStatus").ToString()) %>' CommandName='<%#Eval("StudentID")%>' OnCheckedChanged="chkStudentStatus_CheckedChanged" Checked='<%#Eval("StudentStatus") %>' AutoPostBack="True" /> </td> While check box value changed i was to get the Command Name value in the " chkStudentStatus_CheckedChanged " function 回答1: try this: Short and simple Refrence

Repeater control doesn't have public property ModelType

ⅰ亾dé卋堺 提交于 2019-12-19 17:45:16
问题 I'm trying to use model binding feature of asp.net 4.5. I'm using Repeater control, seting ModelType property on it, but as soon as I run the application, I'm getting parser error, which states, that Repeater doesn't have ModelType public property. Here's markup <ul> <asp:Repeater ID="rptDepartments" runat="server" ModelType="TestWebApp.Models.Department"> <ItemTemplate> <li> <%#: Item.DeptName %> </li> </ItemTemplate> </asp:Repeater> </ul> Any ideas ? I saw plenty of examples of using Model

Azure downloadtostreamasync method hangs

笑着哭i 提交于 2019-12-19 05:21:24
问题 here is the offending code public async static Task<MemoryStream> AsyncReadBlob(string identifier) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference(containerName); MemoryStream memstream = new MemoryStream(); CloudBlockBlob blockBlob = container.GetBlockBlobReference(identifier); await blockBlob.DownloadToStreamAsync(memstream);

ASP.NET / MVC 4 bundling and minification 404 issues on 64-bit IIS 7.5 server

与世无争的帅哥 提交于 2019-12-18 07:46:13
问题 We recently upgraded our project from MVC 3 to MVC 4. We are targeting the .NET 4.0 framework, and our web app is 32-bit due to some references we have to include. The problem we are having is that we converted our bundling / minification from Chirpy to the built-in ASP.NET bundling. The site runs with no problems on 32-bit servers, both Windows Server 2003/IIS 6 and 2008/IIS 7.5 running ONLY .NET 4.0, and our 64-bit development machines. The bundling / minification works fine on all of the

How to implement HttpMessageHandler in Web API?

China☆狼群 提交于 2019-12-18 03:56:16
问题 In an ASP.NET 4.5 MVC 4 Web API project, I want to add a custom HttpMessageHandler . I've changed WebApiConfig class (in \App_Satrt\WebApiConfig.cs), as follows: public static class WebApiConfig { public static void Register(HttpConfiguration config) { config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }, constraints: null, handler: new MyCustomizedHttpMessageHandler() ); } } Then I developed

Bundling resources via bundle.config vs BundleConfig.cs in ASP.NET 4.5 WebForms

一曲冷凌霜 提交于 2019-12-17 18:47:45
问题 Regarding ASP.NET 4.5's new System.Web.Optimization / Microsoft.AspNet.Web.Optimization: Can anyone explain the difference in the use of bundling resources using the BundleConfig.cs class file as opposed to the bundle.config xml file? I've seen some articles showing bundling both js and css in BundleConfig.cs, while others showing bundling js in BundleConfig.cs and css in bundle.config. I guess I don't understand #1) why you wouldn't just do them both one particular way for simplicity - and