background preloader

Misc

Facebook Twitter

How to write to an event log by using Visual C# This step-by-step article shows you how to add your own entries to the operating system's event log by using the Microsoft .NET Framework. Requirements The following list describes the recommended hardware, software, network infrastructure, and service packs that you will need: Microsoft Windows 2000 Professional, Windows 2000 Server, Windows 2000 Advanced Server, or Windows NT 4.0 ServerMicrosoft Visual Studio C# Write to an event log Event logging provides a standard, centralized way for your applications to record important software and hardware events.

Windows supplies a standard user interface for viewing the logs, the Event Viewer. By using the common language's run-time EventLog component, you can connect to existing event logs easily, on both local and remote computers, and write entries to these logs. You can also read entries from existing logs and create your own custom event logs. Complete code listing. How to download large files in ASP.NET Visual Studio .NET. There are many ways to do this; Using Response.WriteFile u can easily download a large fileUsing streame: i.e. by using Response.BinaryWriteAllow direct access to that fileUsing an ISAPI filter Direct Access The most obvious approach to delivering a file across the Internet is to place it in a directory accessible by a web server.

Then anyone can use a browser to retrieve it. As easy as that sounds, there are a number of problems that make this alternative unworkable for all but the simplest of applications. What if, for example, you don’t want to make the file available to everyone? More flexible access control mechanisms run into similar problems. Response.WriteFile Since direct access isn’t realistic, ASP.NET must be a part of the solution.

If (Request.QueryString["File"] ! Response.WriteFile (Request.QueryString["File"]); One of the benefits of using Response.WriteFile is that the security for the request is much more extensible. So what is the downside to using WriteFile? Int count = 0; Advanced Site Functionality - ASP.NET 2.0. ASP.NET Advanced Site Functionality In this tutorial you will learn advanced site functionality, Enhanced Page Framework, To create the Web.Sitemap file, Tracking Traffic with Site Counters and Going Mobile. Enhanced Page Framework The advanced functionalities offered by ASP.NET include site navigation and site counters.

The built in navigation has three components: 1. 2. 3. The Site Map is a container for the hierarchical collection of nodes representing pages in an application. To create the Web.Sitemap file: 1. 2. 3. 4. <%@ Page Language="C#" CodeFile="Default.aspx.cs" Inherits="Default_aspx" %><! 5. Let us examine what we have done in the above code. Click here to view sample code Then we have used a TreeView control to display the same information in a different format. Click here to view sample code Finally we have used a Menu control to display the same information. Another type of control that can be used to display the same information is the SiteMapPath control. Going Mobile Comments. ASP.NET ASHX Handler Tutorial. Some ASP.NET files are dynamic. They are generated with C# code or disk resources. These files do not require web forms. Instead, an ASHX generic handler is ideal. It can return an image from a query string, write XML, or any other data.

Tutorial First, we review the goal of using ASHX files in the ASP.NET web development framework. Url example Getting started. Then:Select the "Generic Handler" item, and you will get a new file with some code in it called Handler.ashx. Autogenerated code What purpose does the autogenerated code in the ASHX file have? Tip:You should not change the interface inheritance or remove either of the members.

Mappings It is often desirable to map an older URL or path to your new ASHX file. Tip:To do this, use urlMappings.Alternatively you can use more complex RewritePath methods. Part of Web.config file: XML <system.web><urlMappings enabled="true"><add url="~/Default.aspx" mappedUrl="~/Handler.ashx"/></urlMappings> ... URL mappings. Uses. 100% Table Height. Occasionally designers may want to center content in a web page and they want it centered both horizontally and vertically.

The traditional method for doing that is to put the content into a table and to assign a values of 100% to the table's HEIGHT attribute and center to the ALIGN attribute. Recently, that approach has become more problematic. You may have used this before and had it work but now, for some reason, new pages you create won't center vertically. You may be changing pages from standard HTML to XHTML and now tables don't respect the 100% HEIGHT attribute. Read on. There are a few things you need to know here. Rendering Modes But why, you ask, did it used to work and now it doesn't? Now don't get ahead of me. Fear not! Why Percentage Height Fails Okay, to begin, maybe I should explain exactly why 100% height fails. What does that do? Using Valid Code You would then apply the fullheight ID to your table like this: Vertical Centering Use the above CSS along with the following HTML:

Basics of Cookies in ASP.NET. Mike Pope Visual Basic User Education Microsoft Corporation January 2003 Summary: Explains how to read and write HTTP cookies in an ASP.NET Web application using Visual Basic. (18 printed pages) Applies to ASP.NET Microsoft® Visual Studio® .NET Web Forms Level: beginning Web programmer Contents Introduction Cookies provide a useful means in Web applications to store user-specific information. This article provides an overview of working with cookies in ASP.NET applications. What Are Cookies? A cookie is a small bit of text that accompanies requests and pages as they go between the Web server and browser. Imagine that when users request a page from your site, www.contoso.com, your application sends not just a page, but a cookie containing the date and time. Later, the user requests a page from your site again. That's the basics of how cookies work. Cookies are used for all sorts of purposes, all relating to helping the Web site remember you.

Cookie Limitations Writing Cookies Reading Cookies. Compression - Create Zip archive from multiple in memory files in C# ASP.NET Cookies Overview. A cookie is a small bit of text that accompanies requests and pages as they go between the Web server and browser. The cookie contains information the Web application can read whenever the user visits the site. For example, if a user requests a page from your site and your application sends not just a page, but also a cookie containing the date and time, when the user's browser gets the page, the browser also gets the cookie, which it stores in a folder on the user's hard disk. Later, if user requests a page from your site again, when the user enters the URL the browser looks on the local hard disk for a cookie associated with the URL. If the cookie exists, the browser sends the cookie to your site along with the page request. Your application can then determine the date and time that the user last visited the site.

Cookies help Web sites store information about visitors. Cookies are used for many purposes, all relating to helping the Web site remember users. Cookie Limitations. Test-Driven Development with Visual Studio 2010 | VisualStudio. ASP.NET ASHX Handler Tutorial.