asp.net-4.5

Strongly typed data binding and generics?

耗尽温柔 提交于 2019-12-03 06:09:41
Suppose I want to bind a generic type (here: Dictionary<string, string> ) to a Repeater using the new ASP.NET 4.5 strongly typed data binding. Then I would have to put down KeyValuePair<string, string> as the ItemType Property of the Repeater. <asp:Repeater id="rpCategories" runat="server" ItemType="System.Collections.Generic.KeyValuePair<string, string>"> There is an obvious problem here: I can not use < or > within the ItemType text! How would one go about this? Is the use of generics possible somehow with the new data binding model? Ian Gilroy This works for me: Code behind protected void

Is it possible to pass a value to the SelectMethod of a Repeater?

谁说我不能喝 提交于 2019-12-03 05:54:15
ASP.Net 4.5 introduces new ways to bind data to controls like the Repeater through the SelectMethod property: <asp:Repeater runat="server" ItemType="MyData.Reference" SelectMethod="GetReferences"> calls the Codebehind method public IEnumerable<Reference> GetReferences() In the scenario of nested repeaters, is it possible to pass a parameter to this select method somehow, so that it fetches different data depending on the Item of the outer repeater? Example: <asp:Repeater runat="server" ItemType="MyData.Reference" SelectMethod="GetReferences(Item.ID)"> should be calling public IEnumerable

The “EnsureBindingRedirects” task failed unexpectedly

元气小坏坏 提交于 2019-12-03 04:12:43
When I create new ASP.NET 4.5 web forms application from vs2012 and update all nuget packages, I receive this error on build: Error 1 The "EnsureBindingRedirects" task failed unexpectedly. System.NullReferenceException: Object reference not set to an instance of an object. at Roxel.BuildTasks.EnsureBindingRedirects.MergeBindingRedirectsFromElements(IEnumerable`1 dependentAssemblies) at Roxel.BuildTasks.EnsureBindingRedirects.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() Henrik

How do you parameterize deployments when using ASP.NET 4.5 publish profiles?

一个人想着一个人 提交于 2019-12-03 03:30:53
The new pubxml files in ASP.NET 4.5 are definitely a step in the right direction. I also like msdeploy 's support for parameters.xml files (even though they are sometimes not as powerful as I would like). Now, how do I combine msdeploy 's parameters and the pubxml files? I would expect that the pubxml files would allow me to provide a setting like <ParametersFile>productionParameters.xml</ParametersFile> or something similar in my production.pubxml file, that would contain values to be merged into web.config when publishing to the production environment. Is that possible or do I have to go

How to use MachineKey.Protect for a cookie?

[亡魂溺海] 提交于 2019-12-03 01:18:35
I want to encrypt the ID that I am using in a cookie. I am using ASP.NET 4.5 so I want to use MachineKey.Protect to do it. Code public static string Protect(string text, string purpose) { if (string.IsNullOrEmpty(text)) return string.Empty; byte[] stream = Encoding.Unicode.GetBytes(text); byte[] encodedValue = MachineKey.Protect(stream, purpose); return HttpServerUtility.UrlTokenEncode(encodedValue); } public static string Unprotect(string text, string purpose) { if (string.IsNullOrEmpty(text)) return string.Empty; byte[] stream = HttpServerUtility.UrlTokenDecode(text); byte[] decodedValue =

Server communication via async/await?

早过忘川 提交于 2019-12-02 10:52:56
问题 I want to create Socket message sending via TAP via async/await. After reading this answer and this one - I decided to create a fully working sample : So what have I tried : I took the TAP extenstion methods from here (all ok) : and I test it in console cmd : Reciever Code public static class SocketExtensions { public static Task<int> ReceiveTaskAsync(this Socket socket, byte[] buffer, int offset, int count) { return Task.Factory.FromAsync<int>( socket.BeginReceive(buffer, offset, count,

Server communication via async/await?

China☆狼群 提交于 2019-12-02 04:41:33
I want to create Socket message sending via TAP via async/await. After reading this answer and this one - I decided to create a fully working sample : So what have I tried : I took the TAP extenstion methods from here (all ok) : and I test it in console cmd : Reciever Code public static class SocketExtensions { public static Task<int> ReceiveTaskAsync(this Socket socket, byte[] buffer, int offset, int count) { return Task.Factory.FromAsync<int>( socket.BeginReceive(buffer, offset, count, SocketFlags.None, null, socket), socket.EndReceive); } public static async Task<byte[]>

Repeater control doesn't have public property ModelType

坚强是说给别人听的谎言 提交于 2019-12-01 16:40:25
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 Binding in conjuction with repeater control in the web. I'm using VS 2012 RC. It looks like the

The predefined type 'System.Threading.Tasks.Task' is defined in multiple assemblies in the global alias

你离开我真会死。 提交于 2019-12-01 15:13:34
I just have set up a new asp.net mvc 4 project, using the latest .net framework (4.5) in combination with Visual studio 2012. After I added some classes, side projects etc. I suddently notice that I'm receiving 5 times the same warning when I compile the project. The warning states: ASPNETCOMPILER : warning CS1685: The predefined type 'System.Threading.Tasks.Task' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\mscorlib.dll' So now I'm wondering in which assemblies are this type

The predefined type 'System.Threading.Tasks.Task' is defined in multiple assemblies in the global alias

旧城冷巷雨未停 提交于 2019-12-01 14:06:07
问题 I just have set up a new asp.net mvc 4 project, using the latest .net framework (4.5) in combination with Visual studio 2012. After I added some classes, side projects etc. I suddently notice that I'm receiving 5 times the same warning when I compile the project. The warning states: ASPNETCOMPILER : warning CS1685: The predefined type 'System.Threading.Tasks.Task' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files (x86)\Reference Assemblies