.net-4.0

How to use Routing ASP.NET 4 WebForms with Query String?

谁说我不能喝 提交于 2019-12-04 05:05:32
First, this is not MVC, WebForms only.. I'm using routing to keep my site backwards compatible for our clients, while make my project organized. I'm also thinking of moving our encrypted query string to a more friendly url. How this works is our clients have to bookmark a huge encrypted url to prevent them from guessing our other clients by changing an id around. But instead of having this huge url, wanted to add a route like LoginClientName.aspx for each client and have the encrypted query string hard coded or maybe in database. But don't see a way to add a query to the MapPageRoute.. Was

Mysterious disappearing reference

北城余情 提交于 2019-12-04 04:23:32
问题 I have what seems to be a very strange problem with a windows forms application. I am a web developer and I have limited experience of developing windows forms application. I am working on an ecommerce web site which stores product images in the database as blobs. In order to make it easier to bulk import images I am writing a small windows forms utility that uses the existing website bll library. I am using Visual studio 2010 c# and .net 4. I created a new windows forms project in my

Using UNC path with credentials

别来无恙 提交于 2019-12-04 04:22:44
I'm working on an app that uses an UNC path to access remote files in the same LAN. The problem is that when access is attempted it throws an exception related to Windows credentials. Is there a way to add credentials to my UNC path? Thank you It might be useful for you to use the NetUseAdd function from the windows api http://msdn.microsoft.com/en-us/library/windows/desktop/aa370645(v=vs.85).aspx . It allows you to access a directory through its UNC path. Derek Risling Looks like Win32 APIs are the most common way to handle this. Check out this SO post Accessing a Shared File (UNC) From a

Why aren't IStructuralEquatable and IStructuralComparable generic?

风流意气都作罢 提交于 2019-12-04 04:17:38
System.Collections.IStructuralEquatable and System.Collections.IStructuralComparable were added in .NET 4, but why aren't they generic, like IEquatable<T> and IComparable<T> ? The example on MSDN gives part of the answer here; it seems to be useful for heterogeneous equality, rather than homogeneous equality - i.e. for testing whether two objects (/values) of potentially different types should be considered equal. In such scenarios, it is extremely likely that the calling code is dealing with object (to represent heterogeneous data). And generic methods don't play nicely then. 来源: https:/

Cannot insert data into Local Database in WPF

瘦欲@ 提交于 2019-12-04 04:08:10
问题 In a project, I have a local database, (I am using the datagrid to view the data), but the problem is that when I insert into database using the insertion query, the insertion is not lasting, i.e. when I rerun the application, the database is not changed and the changes are not reflected in the database view (view table data in Visual Studio). The insertion query is: string dbCon = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName + "\\MyDatabase

Problem with System.Net.Dns.GetHostEntry(dnsServer) on .NET 4.0

北城余情 提交于 2019-12-04 03:59:10
I have been using the following code for months (without problem) in a .NET 2.0/3.5 environment: string server="192.168.1.3"; IPHostEntry ipe = System.Net.Dns.GetHostEntry(server); IPAddress ipa = ipe.AddressList[0]; IPEndPoint ipep = new IPEndPoint(ipa, (int)UdpServices.Domain); Here, server is hardcoded to an IP address, but in my application it could potentially be something like "server.test.com". When converting my project to .NET 4.0, this code stopped working when directly passing an IP address (still works with a hostname). It crashes with this exception: System.Net.Sockets

Thread Safe Event Calls

萝らか妹 提交于 2019-12-04 03:51:51
A common practice to avoid race conditions (in multi-threaded apps) when triggering events is this: EventHandler<EventArgs> temp = SomeEvent; if (temp != null) temp(e); "Remember that delegates are immutable and this is why this technique works in theory. However, what a lot of developers don't realize is that this code could be optimized by the compiler to remove the local temp variable entirely. If this happens, this version of the code is identical to the first version, so a NullReferenceException is still possible." The problem (according to the book) is that "this code could be optimized

PDF footer at the bottom using iTextSharp

余生颓废 提交于 2019-12-04 03:48:58
问题 I am trying to create a pdf document in c# using iTextSharp 5.0.6. I want to add header and footer to every page in OnStartPage and OnEndPage events respectively. In case of footer there is a problem that the footer is created right where the page ends whereas I would like to be at the bottom of page. Is there a way in iTextSharp to specify page height so that footer is always created at the bottom. Thanks! 回答1: The page's height is always defined: document.PageSize.Height // document

String comparison in dotnet framework 4

一曲冷凌霜 提交于 2019-12-04 03:17:44
问题 I will explain my problem(excuse my bad English), I have a .NET exe in which every milliseconds of processing is very important. This program does lots of string comparison (most of it is string1.IndexOf(string2, StringComparison.OrdinalIgnoreCase) ). When i switch to framework 4, my program time is twice than before. I searched for explanation and I found that the function IndexOf(s, OrdinalIgnoreCase) is much slower in framework 4 (I did test with a simple console application and in a loop

ViewStateMode Disabled but still getting ViewState element

早过忘川 提交于 2019-12-04 03:11:46
问题 I have a ASP.NET 4.0 webforms site where I have the MasterPage so it is set to ViewStateMode="Disabled" along with the content placeholders being set similarly. When I'd view my page I'd still see a ViewState field rendered, I then tried adding the ViewStateMode="Disabled" to the page level also but that didn't change anything. 回答1: I'm not aware of latest changes on ViewState for the framework 4 but you have to take into account that the ViewState field rendered to the client has 2