.net-4.0

ASP.Net Application Warmup - Exposing Collections

会有一股神秘感。 提交于 2019-12-24 15:26:34
问题 My MVC application currently uses the Global.asax , Application_Start method to load tons of data, and then exposes it as collections. For example: Current Usage Example: // Global.asax public static DataRepository Repository { get; set; } protected void Application_Start() { // All the normal stuff... // Preload this repository. DataRepository = new DataRepository(); } // HomeController.cs Example public ActionResult Index(){ return Json(MyApplication.Repository.GetSomeCollection(),

Clean Web.Config file in Asp.NET 4.0?

痴心易碎 提交于 2019-12-24 15:26:28
问题 Okay, I am wondering having clear web.config file could be good but you know some shared web hosting companies don't allow us to touch things like machine.config and etc. So If a lot of things have been moved onto machine.config, then will we be allowed to change things like we used to through web.config file. 回答1: Nothing is changing in this regard with ASP.NET 4.0: the way the ASP.NET configuration model has always worked is that you can override settings in machine.config with a web.config

Stamping / Tagging / Branding Object Instances

爱⌒轻易说出口 提交于 2019-12-24 15:14:48
问题 I have a routine which accepts an object and does some processing on it. The objects may or may-not be mutable. void CommandProcessor(ICommand command) { // do a lot of things } There is a probability that the same command instance loops back in the processor. Things turn nasty when that happens. I want to detect these return visitors and prevent them from being processed. question is how can I do that transparently i.e. without disturbing the object themselves. here is what i tried Added a

Entity Framework 4 + Self-Tracking Entities + ASP.NET Dynamic Data = Error

为君一笑 提交于 2019-12-24 15:05:37
问题 I'm using the Self-Tracking Entities codegen option in EF4 (VS2010 RC), and I'm trying to use Dynamic Data to build a quick-and-dirty website for editing. The Entities, Data Context, and EDMX files are all in separate assemblies, and this model works well when I call everything in code. But when I try to use it with Dynamic Data, right off the bat I get a whole lotta FAIL: Could not find the CLR type for 'Core.Recording'. at System.Data.Metadata.Edm.MetadataWorkspace.GetObjectSpaceType

Match Table w/ Regex

梦想的初衷 提交于 2019-12-24 13:59:56
问题 I'm trying to match a table w/ regex but I'm having some issues. I can't figure out exactly why it will not match properly. Here is the HTML: <table class="integrationteamstats"> <tbody> <tr> <td class="right"> <span class="mediumtextBlack">Queue:</span> </td> <td class="left"> <span class="mediumtextBlack">0</span> </td> <td class="right"> <span class="mediumtextBlack">Aban:</span> </td> <td class="left"> <span class="mediumtextBlack">0%</span> </td> <td class="right"> <span class=

Start, Stop, Pause and Continue a very long running method

我们两清 提交于 2019-12-24 12:35:18
问题 I have a method which is running very long. I want to be able to stop, pause and continue the execution of that method.I viewed this question and the answer is nice, but I want to use more general library like TPL. TPL has a cancellation mechanism, but I can't find pause/continue functionality. edit Thanks for all answers. But the problem is that I don't write that "long running" method, I just call that method. 回答1: The easiest way to implement this is with a BackgroundWorker control. It

.NET Denying Access to Directories After Copy Operations

一个人想着一个人 提交于 2019-12-24 12:12:54
问题 I'm performing a "safe" copy of a directory over another directory as follows: Given the source C:\Source and target C:\Target Copy C:\Source to C:\Target-incoming Move C:\Target (if it exists) to C:\Target-outgoing Move C:\Target-incoming to C:\Target Delete C:\Target-outgoing (if it exists) If any of the first three steps fail, I'll attempt to put things back as they were to prevent data loss. However, the move of C:\Target-incoming to C:\Target fails with "Access to the path C:\Target

WCF : How to Set MaxReceivedMessageSize Quota

核能气质少年 提交于 2019-12-24 11:29:45
问题 I have a WCF Service. I get the following message when I run the client application The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. Also i added MaxReceivedMessageSize property in related config in client and server projects. My config in client application is : <system.serviceModel> <bindings> <basicHttpBinding> <binding name="RPBasicHttpBinding" allowCookies=

Getting relative path of file?

我怕爱的太早我们不能终老 提交于 2019-12-24 11:22:05
问题 I have a file called settings.xml located at: c:\solution1\solution1\data\settings.xml Right now, I am doing: XDocument doc = XDocument.Load(@"c:\solution1\solution1\settings.xml"); I can't figure how to do it with a relative path. 回答1: If you mean relative to your executable, you can use string exeLocation = System.Reflection.Assembly.GetExecutingAssembly().CodeBase Note the frequently suggested System.Reflection.Assembly.GetExecutingAssembly().Location will get the path where the assembly

Why can't I leave a TextBox using tab?

旧巷老猫 提交于 2019-12-24 10:46:35
问题 I have this code: public static void AddDefaultTextFromTag(params TextBox[] textBoxes) { foreach (TextBox oTextBox in textBoxes) { bool isPasswordChar = oTextBox.UseSystemPasswordChar; oTextBox.Enter += (sndr, evnt) => { if (((TextBox)sndr).Text == ((TextBox)sndr).Tag.ToString()) { ((TextBox)sndr).Text = ""; ((TextBox)sndr).UseSystemPasswordChar = isPasswordChar; ((TextBox)sndr).ForeColor = SystemColors.WindowText; } }; oTextBox.Leave += (sndr, evnt) => { if (((TextBox)sndr).Text.Trim().Count