.net-4.0

MVC 4 routing - ignore requests for images

ぐ巨炮叔叔 提交于 2019-12-13 02:47:33
问题 I'm trying to prevent users from making requests to access images on their own in my web application, so the user shouldn't be allowed to make this type of request: sitename/Images/test.jpg I've tried specifying a route to ignore in RouteConfig.cs but it still serves images on their own, is there a way to prevent this? This is what I've tried: routes.IgnoreRoute("{file}.jpg"); routes.IgnoreRoute("Images/{file}.jpg"); routes.IgnoreRoute("{resource}.jpg"); routes.IgnoreRoute("Images/{resource}

Ignore some inherited properties in EF6 code first mapping(.NET4 not .NET4.5)

蓝咒 提交于 2019-12-13 02:26:55
问题 I'm using EF6 code first with .NET4(I should deliver the project on win xp so I couldn't configure it with .NET4.5) in a win Form project. I have a BaseEntity class that all other entities inherited from it: public abstract class BaseEntity { public int Id {get; set;} public int X {get; set;} public int Y {get; set;} } public class Calendar:BaseEntity { // properties } How could I Ignore X,Y properties in my all entities without writing following code for each entity? modelBuilder.Entity

ThreadPool and Memory (BTStackServer) exception - .NET

不羁的心 提交于 2019-12-13 02:25:51
问题 In continuation with my problem here, I created a test app that uses ThreadPool threads to send emails. Here's the code I am using. protected void btnSend_Click(object sender, EventArgs e) { EmailInfo em = new EmailInfo { Body = "Test", FromEmail = "test@test.com", Subject = "Test Email", To = "test@test.com" }; //txtNumEmails is a textbox where I can enter number of emails to send for (int i = 0; i < Convert.ToInt32(this.txtNumEmails.Text); i++) { bool bResult = ThreadPool.QueueUserWorkItem

When server GC is ignored?

狂风中的少年 提交于 2019-12-13 02:24:54
问题 I found this in the MSDN article about .NET 4 GC : http://msdn.microsoft.com/en-us/library/ee787088.aspx "Workstation garbage collection is always used on a computer that has only one processor , regardless of the setting. If you specify server garbage collection, the CLR uses workstation garbage collection with concurrency disabled." I would think that they mean one physical CPU. However I run my app in server GC mode (or at least I thought I did) on a server with one CPU but 8 HT logical

Cannot convert from method group to System.Func<string>

為{幸葍}努か 提交于 2019-12-13 02:12:10
问题 I'm playing a bit with the .Net 4.0 Task class to download the google webpage in background using a thread. The problem is that if my function has 1 or more parameters, the application won't compile (idk how to pass that parameter). So I wonder how can I pass the function's parameter in the DoWork() method. This works: public Task<String> DoWork() { //create task, of which runs our work of a thread pool thread return Task.Factory.StartNew<String>(this.DownloadString); } private String

How to disable HTML tag validation on a specific TextBox?

主宰稳场 提交于 2019-12-13 02:05:39
问题 I have a form where one of the fields would allow entry of HTML tags. <asp:TextBox ID="someID" runat="server" TextMode="MultiLine" /> In this field I have a RequiredFieldValidator validation only. Unfortunately, after any PostBack if the content of any of the fields includes HTML tags or any other potentially dangerous code - the entire ViewState is cleaned. Setting ValidateRequest to false does not help. I'm using IIS 7.5 and .NET 4.0. Any ideas? 回答1: You also need to set the <system.web>

.NET 4.0 AppDomain: obsoleted Evidence

社会主义新天地 提交于 2019-12-13 01:40:54
问题 I am a .NET student and currently we are learning about Application Domains. We were given the following example code (for .NET 3.5). As expected, it throws a SecurityException. Note: TestApp.exe is added as a reference in the project. Dim file As String = "TestApp.exe" Dim hostEvidence As Object() = {New Zone(SecurityZone.Internet)} Dim appDomainEvidence As Evidence = New Evidence(hostEvidence, Nothing) Dim d As AppDomain = AppDomain.CreateDomain("MyDomain", appDomainEvidence) d

Problems with extending s.ds.am.UserPrincipal class

☆樱花仙子☆ 提交于 2019-12-13 01:36:01
问题 I have been trying to extend the s.ds.am.UserPrincipal class in VS 2010 VB app as I require access to AD User properties that are not by default a part of the UserPrincipal. This is a new concept to me and I have found some useful code on here as well but I have run into 2 problems with my extensions that I cannot seem to figure out. Problem 1: When I attempt to use my UserPrincipalEx to retrieve a user I receive the following error. ERROR: Principal objects of type MyApp.UserPrincipalEx can

Dynamically adding WCF Data Services Endpoints

谁都会走 提交于 2019-12-13 00:25:34
问题 I've been researching oData and WCF DataServices and I think it would work great for my project. However, each of our clients have their own database. So, is there a way to dynamically create a WCF endpoint that I could point to a database. The schema for all the databases are identical. For Example: Client1 needs DB1, they would use the URL: https://webservice.com/wcf/Client1 which would use DB1 Client2 needs DB2, they would use the URL: https://webservice.com/wcf/Client2 which would use DB2

Targeting and Compiling For .NET Framework 4.0 with Mono

老子叫甜甜 提交于 2019-12-13 00:20:03
问题 Generally the Managed executables I compile with the Mono GMCS on Ubuntu, run fine with .NET Framework 2.0 on Windows, but don't work with any other version. Is it possible to compile exes that run on the .NET Framework 4 with Mono? 回答1: Instead of gmcs , use the dmcs front end of the Mono compiler which targets the 4.0 runtime. 来源: https://stackoverflow.com/questions/8739406/targeting-and-compiling-for-net-framework-4-0-with-mono