asp.net-4.0

Response.Redirect() vs Response.RedirectPermanent()

╄→гoц情女王★ 提交于 2019-12-05 08:44:49
I am new to ASP.Net 4.0, and have seen a new feature called Response.RedirectPermanent() . I have checked a few articles, but I'm unable to understand clearly the actual meaning and difference of Response.RedirectPermanent() over Response.Redirect() . According to Gunnar Peipman , Response.Redirect() returns 302 to browser meaning that asked resource is temporarily moved to other location. Permanent redirect means that browser gets 301 as response from server. In this case browser doesn’t ask the same resource from old URL anymore – it uses URL given by Location header. Why do I need to check

ASP.NET control to render a <div>

烂漫一生 提交于 2019-12-05 08:33:11
问题 The Label control in ASP.NET seems to render <span> tags, but is there a server control to render HTML within a <div> ? Sure, I could set display: block and it might look the same, but I'd rather not be nesting divs inside spans. Also I'd prefer not to use <%= MyVariable %> because that might not behave nicely on postbacks. Any suggestions, please? 回答1: I think you need HtmlGenericControl class. It has a constructor which accepts a string variable which initializes a new instance of the

Escape Key Issues with Update Panel

心已入冬 提交于 2019-12-05 08:29:01
while hitting ESC key twice when on a page containing an update panel with a any control inside, say textbox or listbox im getting a System.ArgumentException: Invalid postback or callback argument . I have checked in remaining browsers its working fine but in Internet Explorer 8 its creating above said problem. the possible solution i found, is making EnableEventValidation="false" either at page level or webconfig or disabling escape key . i dont want to go with 2 former solutions as either my site security will compromise and i dont want my escape key to disable. Any Suggestions/Ideas

Custom validator fires but does not prevent postback

断了今生、忘了曾经 提交于 2019-12-05 08:13:14
I've seen a lot of questions about this already, but I'm stumped! Please help! I have a customvalidator. It's firing but it's not preventing postback. Please help me in doing so! I can see that console.log registers before the post. But, it posts back anyway. How do I prevent the postback? I've tried adding a control to validate, and validate empty text equal to true. I also tried adding e.preventdefault, which did not work :( How can I prevent the postback? <script type="text/javascript"> //<![CDATA[ function validateWhyUnlikely(source, args) { console.log(1); args.isValid = false; } //]]>

ASP.NET 4.0 Routing and Subfolders

谁都会走 提交于 2019-12-05 07:01:45
问题 I have a folder structure like this: www.mysite.com/About/About.aspx I have a link in a user control like this: <a href="~/About/About" id="aboutLink" title="About" runat="server">About</a> And in my RegisterRoutes() method, I have this: routes.MapPageRoute("", "About/About/", "~/About/About.aspx"); It works but produces the following URL: www.mysite.com/About/About What I would like is this: www.mysite.com/About Is this possible with out-of-the-box 4.0 routing? UPDATE 2 - 05-14-2010:

IRegisteredObject not working as expected

杀马特。学长 韩版系。学妹 提交于 2019-12-05 07:00:34
问题 Background I'm working on an ASP.NET 4 web site (not web application). I'm trying to use IRegisteredObject to allow some long-running code to run in a non-request thread. For testing, I've set the IIS 7.5 application pool's recycle interval to low values so that it will try to recycle while the background thread is running. Code public class AspFriendlyBackgroundJob { private readonly object key = new object(); private readonly Task task; public AspFriendlyBackgroundJob(Action work) { lock

ThreadPool and sending emails

社会主义新天地 提交于 2019-12-05 06:55:32
问题 We are currently sending emails to users asynchronoulsy using the ThreadPool. Essentially, we have logic that comes down to this: for (int i=0 < i < numUsers; i++) { //Pre email processing unrelated to sending email string subject = GetSubject(); string message = GetMessage(); string emailAddress = GetEmailAddress(); EmailObj emailObj = new EmailObj { subject = subject, message = message, emailAddress = emailAddress }; bool sent = ThreadPool.QueueUserWorkItem(new WaitCallback(SendEmail),

Is page output cache stored in ASP.NET cache object?

情到浓时终转凉″ 提交于 2019-12-05 06:52:35
I need to enable caching in my asp.net application, but I do not want to use the webserver's memory for holding cache objects. If I add the page directive for output caching will the page be stored in the asp.net cache object? Thanks! The default behaviour is to store the content in memory in the same way as HttpRuntime.Cache (actually in an internal HttpRuntime.CacheInternal which behaves similarly to the publicly visible cache), but in ASP.NET 4.0 you can write your own provider to store the content however you wish. This a nice introduction to implementing a provider and using it in your

After upgrading to .Net 4.0, I'm getting the exception “Could not load file or assembly 'System.Windows, Version=2.0.5.0'”

安稳与你 提交于 2019-12-05 06:04:11
We recently upgraded our web app from 3.5 to 4.0. Now after I login and load a page with Microsoft ScriptManager on it, I get: Could not load file or assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified. It only happens the first time, reload the page and everything works. UPDATE: We have all Silverlight v4 projects.I found the System.Windows.dll in the C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0 directory. Why would it look for version 2.0? Here's the

Problem with <system.web.extensions> config group when upgrading to .NET 4.0

一世执手 提交于 2019-12-05 02:36:34
So we've upgraded our site from 3.5 SP1 -> .NET 4. When we ran the site, we got an Internal Server Error (500), stating the following configuration group could not be read: <system.web.extensions> <scripting> <scriptResourceHandler enableCompression="true" enableCaching="true" /> <webServices> <jsonSerialization maxJsonLength="999999" /> </webServices> </scripting> </system.web.extensions> We commented out this section and the website ran fine (but now we are getting problems with JSON - because of the above required property). We've read threads on this issue, and most of them say "Your