Saturday, March 3, 2012

What is ASP.NET MapPath?

ASP.NET MapPath Resolves Virtual, Physical Paths

You need to use MapPath to resolve virtual paths and physical paths. You run the ASP.NET development server on your local machine, but the paths on it are not the same as they are on your server. Here we use MapPath to find physical paths and file locations, using the C# programming language.

Introduction
First, in ASP.NET the ~ tilde indicates the root of a virtual path. We need the tilde because otherwise ASP.NET can't figure out if a path is absolute or relative. Let's look at some virtual paths and what they might map to.

Virtual paths:

~/App_Data/Sample.xml
~/
~/Map.txt

Physical paths:

C:\Website\Files\Sample.xml
C:\Website\Default.aspx
C:\Website\Map.txtMapPath
For example
You can call MapPath in any C# file in your ASP.NET website. You may want to include the System.Web namespace first, but this is not required. Make sure you are looking at a C# file in your ASP.NET project and then add some code that looks similar to parts of the following.

Example code that uses MapPath

using System;
using System.Web;



public class Example
{
public Example()
{
// This will locate the Example.xml file in the App_Data folder.
// ... (App_Data is a good place to put data files.)
string a = HttpContext.Current.Server.MapPath("~/App_Data/Example.xml");

// This will locate the Example.txt file in the root directory.
// ... This can be used in a file in any directory in the application.
string b = HttpContext.Current.Request.MapPath("~/Example.txt");
}
}
Using Server.MapPath. Here we note that the Server.MapPath does the same thing as the Request.MapPath method. In this example, the two versions will do the same thing. There may be some differences in different usage scenarios, but in those cases a more detailed guide would be helpful. The two methods are interchangeable in most ASP.NET projects.

XML files
Here we note that you can use the MapPath method to access many different paths on the server. There is an entire article here about XElement examples. XElement is an XML object that can open a file, much like StreamReader.

Virtual hosts security
Here we note that if you are using a virtual shared host, there may be problems in your code related to file permissions and security checks. The problem may not be MapPath at all. MapPath is very simple and unless you have a typo in the argument, it won't cause you any problems.

Performance
You might be interested to find that MapPath performance is over 1000 times slower than a simple string append. Therefore, it could be worthwhile to cache the paths, in a technique similar to that in my article about appSettings caches.

Summary
MapPath is a method that resolves virtual paths to machine paths. It has great utility for XML and some other data files. It can work as a bridge between website-specific virtual paths, and a physical path that most .NET I/O methods will require.







We collect videos & images from online sites like youtube and some other websites which provide them. And most of the News is also gathered from other online websites. Any material downloaded or otherwise obtained through the use of the service is done at your own discretion and risk and that you will be solely responsible for any damage to your computer system or loss of data that results from the download of any such material. If you feel that the content on the site is illegal or Privacy please contact us at srinuchalla@gmail.com and such videos, images or any Content will be removed with immediate effect.

Basic guide lines for .Net(C#, ASP.NET) programming




Technical guide lines for  .Net(C#, ASP.NET) programming

1) Sort all the namespaces alphabetically as shown below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

2) Use #region for Segregation

#region Page Event Handlers
#region UI Event Handlers
#region Helper Methods

3) Always initialize String type with String.empty

Wrong:
String CardNo = "";

Correct:
String CardNo = String.empty;



4)Avoid parameters

When you call any method in the C# language that was not in-lined, the run time will actually physically copy the variables you pass as arguments to the formal parameter slot memory in the called method. It causes stack memory operations and incurs a performance hit. It is faster to minimize arguments, and even use constants in the called methods instead of passing them arguments.

5) Avoid local variables

When you call a method in your C# program, the run time allocates a separate memory region to store all the local variable slots. This memory is allocated on the stack even if you do not access the variables in the function call. Therefore, you can call methods faster if they have fewer variables in them.

  6) Use arrays
In the .NET Framework, you have many options for collections, such as the List type, and various other types such as ArrayList. While these types are convenient and should be used when necessary, it is always more efficient to use a simple array if this is possible. The reason for this is that the more complex collections such as List are actually composed of internal arrays. They add logic to avoid the burden of managing the array size on each use. However, if you do not need this logic, or can adjust your code so that the logic is not needed, using an array will be faster.

 
7)Use StringBuilder
If you are doing significant appending of strings using the C# language, the StringBuilder type can improve performance. This is because the string type is immutable and cannot be changed without reallocating the entire object. Sometimes, using strings instead of StringBuilder for concatenations is faster; this is typically the case when using very small strings or doing infrequent appends.

8) Use static fields
Here, we note that static fields are faster than instance fields, for the same reason that static methods are faster than instance methods. When you load a static field into memory, you do not need the runtime to resolve the instance expression. Loading an instance field must have the object instance first resolved. In fact, even in an object instance, loading a static field is faster because no instance expression instruction is ever used.

9) Comparing Non-Case-Sensitive Strings

In an application sometimes it is necessary to compare two string variables, ignoring the cases. The tempting and traditionally approach is to convert both strings to all lower case or all upper case and then compare them, like such:
str1.ToLower() == str2.ToLower()

However repetitively calling the function ToLower() is a bottleneck in performace. By instead using the built-in string.Compare() function you can increase the speed of your applications.

To check if two strings are equal ignoring case would look like this:

string.Compare(str1, str2, true) == 0 //Ignoring cases
The C# string.Compare function returns an integer that is equal to 0 when the two strings are equal.

10) Use && and || operators

When building if statements, simply make sure to use the double-and notation (&&) and/or the double-or notation (||), (in Visual Basic they are AndAlso and OrElse).

If statements that use & and | must check every part of the statement and then apply the "and" or "or". On the other hand, && and || go thourgh the statements one at a time and stop as soon as the condition has either been met or not met.

Executing less code is always a performace benefit but it also can avoid run-time errors, consider the following C# code:

if (object1 != null && object1.runMethod())
If object1 is null, with the && operator, object1.runMethod()will not execute.
 If the && operator is replaced with &, object1.runMethod() will run even if object1 is already known to be null, causing an exception.

11)Lazy Instantiation/Initialization

The Singleton design pattern is often used to provide a single global instance of a class. Sometimes it's the case that a particular singleton won't be needed during an application run. It's generally good practice to delay the creation of any object until it's needed, unless there's a specific need to the contrary - for instance, to pre-cache slow-initializing objects such as database connections. The "double-checked locking" pattern is useful in these situations, as a way to avoid synchronization and still ensure that a needed action is only performed once. Lazy initialization is a technique that can enhance the performance of an entire application through object reduction.


12)Working with Objects and Value Types

Objects are expensive to use, partly because of the overhead involved in allocating memory from the heap (which is actually well-optimized in .NET) and partly because every created object must eventually be destroyed. The destruction of an object may take longer than its creation and initialization,especially if the class contains a custom finalization routine. Also, the garbage collector runs in an indeterministic way; there's no guarantee that an object's memory will be immediately reclaimed when it goes out of scope, and until it's collected, this wasted memory can adversely affect performance.

It's necessary to understand garbage collection to appreciate the full impact of using objects. The single most important fact to know about the garbage collector is that it divides objects into three "generations": 0, 1, and 2. Every object starts out in generation 0; if it survives (if at least one reference is maintained) long enough, it goes to 1; much later, it transitions to 2. The cost of collecting an object increases with each generation. For this reason, it's important to avoid creating unnecessary objects, and to destroy each reference as quickly as possible. The objects that are left will often be long-lived and won't be destroyed until application shutdown.

13) Using the 'Sealed' Keyword
Wherever extensibility is not required, you should use the sealed keyword. This makes your design easier to understand, as someone can tell at a glance if a certain class or method isn't meant to be extended or overridden. It also increases the chances that the compiler will inline code.

15) Use Page.IsPostback to avoid unnecessary processing on a round trip.




 



We collect videos & images from online sites like youtube and some other websites which provide them. And most of the News is also gathered from other online websites. Any material downloaded or otherwise obtained through the use of the service is done at your own discretion and risk and that you will be solely responsible for any damage to your computer system or loss of data that results from the download of any such material. If you feel that the content on the site is illegal or Privacy please contact us at srinuchalla@gmail.com and such videos, images or any Content will be removed with immediate effect.

Optimizing C# Application

 Very nice article...

check it out http://www.vcskicks.com/optimize_csharp_code.php

 


We collect videos & images from online sites like youtube and some other websites which provide them. And most of the News is also gathered from other online websites. Any material downloaded or otherwise obtained through the use of the service is done at your own discretion and risk and that you will be solely responsible for any damage to your computer system or loss of data that results from the download of any such material. If you feel that the content on the site is illegal or Privacy please contact us at srinuchalla@gmail.com and such videos, images or any Content will be removed with immediate effect.

Tuesday, August 9, 2011

Equinox: Difference Between ULIP and Traditiona​l Plans

Equinox: Difference Between ULIP and Traditiona​l Plans

We collect videos & images from online sites like youtube and some other websites which provide them. And most of the News is also gathered from other online websites. Any material downloaded or otherwise obtained through the use of the service is done at your own discretion and risk and that you will be solely responsible for any damage to your computer system or loss of data that results from the download of any such material.If you feel that the content on the site is illegal or Privacy please contact us at srinuchalla@gmail.com and such videos, images or any Content will be removed with immediate effect.

Difference Between ULIP and Traditiona​l Plans


Srinivasa was grappling with a strange situation. He wanted to invest in an insurance product to take care of his risk as well as investment requirements, but he was not able to decide between “ULIP” or a Traditional insurance product (e.g. endowment plan) Fortunately he had ready help handy – his financial advisor – Anil.


Anil explained that both the types of insurance products have their own interesting nuances and, he went about explaining them as given below.
 
ULIP vs. Traditional Plan:

Definition:

ULIP means a “Unit Linked Insurance Plan.” It combines the characteristics of a mutual fund and life insurance product. Part of the premium goes into buying life insurance cover while the remaining part of the premium is invested in an asset class (Equity/Debt), based on one’s choice. Asset class investment is made after deduction of known charges.


Traditional Plan – Money Back Plan/Endowment Plan/ Term Plans. Before the advent of ULIP’s, these were the instruments of choice, for Insurance and Investment. However, they offered no option to choose between various asset classes and the investments were made solely at the discretion of the insurance company. Traditional plans provided returns in the form of sum insured plus bonus (if and when declared). The amount of bonus depends upon profits made by the insurance company and the declaration of the bonus at the sole discretion of the life insurance company.


Since traditional plans offer assured returns, a major portion of the premium is required to be invested in risk-free securities, as per Insurance Regulatory and Development Authority (IRDA) mandate.
 
 
Investments:

In ULIP, at the time of buying a life insurance plan, the policyholder has the option of choosing the type of fund depending upon the asset class (equity/debt) and the investment strategy of the policyholder.
 
Further, the policyholder can also switch the units between the available funds in a unit-linked life insurance product based on prevailing market conditions. In a Traditional life insurance plan, the investment decisions are made by the life insurance companies, where the investment is done in primarily in Government Securities and Corporate Bonds.


Transparency:

In a unit-linked life insurance product, before investing an individual should know the various charges upfront, namely:



• Premium Allocation Charge

• Fund Management Charge

• Mortality Charge

• Policy Administration Charge

• Surrender/Discontinuance Charge

• Switching Charge

• Redirection Charge

• Partial Withdrawal Charge
 
The amount after deduction of applicable charges called “Residual Amount” is finally invested in the fund chosen by the policyholder.Also, the current investment value of the funds invested is readily available to the policyholders in form of Net Asset Value (NAV), as this is declared regularly by an insurance company.

Nature:


Traditional life insurance plans are aimed primarily to encourage savings and have adequate protection or life cover for the policyholder. Traditional policies are considered risk-free, as they provide fixed returns in case of death or maturity of the term. ULIPs in addition to providing protection cover are seen as tool for wealth generation because of the options of investing the policyholder‘s funds in various fund types depending upon the investment strategy and risk appetite -, therefore provide opportunities of higher returns. However, one must note that unlike the traditional life insurance plans the ULIPs are subject to the investment risks associated with the capital markets.In addition,a ULIP investor has the flexibility to switch funds, determine the amount of investment and withdraw funds partially or systematically.
 
Decision Maker:

The choice of investments in ULIP lies with the policyholder/investor. Therefore, depending upon the risk appetite, an individual can choose either a traditional life insurance plan or a unit-linked life insurance plan. ULIP is the instrument of choice for an “Active Investor.”

For “Passive Investors,” whose priority is savings and security along with protection cover, a traditional life insurance policy may be better suited.

The age of an individual and number of dependents is also directly proportional to his/her risk taking ability. The risk appetite is higher for younger people considering the larger amount of time they have to remain invested to average out market fluctuation.


This article is copied from Max New York Life Insurance..........





We collect videos & images from online sites like youtube and some other websites which provide them. And most of the News is also gathered from other online websites. Any material downloaded or otherwise obtained through the use of the service is done at your own discretion and risk and that you will be solely responsible for any damage to your computer system or loss of data that results from the download of any such material. If you feel that the content on the site is illegal or Privacy please contact us at srinuchalla@gmail.com and such videos, images or any Content will be removed with immediate effect.

Tuesday, August 2, 2011

ఇది నిద్రయా లేక అమృత భాండమా....!


ఈ మత్తులో జగమే ఊగుతోంది

కానీ నా శరీరం ఊగుతూ ఆగలేనంటూంది

మనసు దేనికో ఆరాటపడుతోంది

కళ్ళు ఎందుకో మిటమిటమంటున్నాయి

ఇది నిద్రయా లేక అమృత భాండమా....!      
 

మధుర క్షణాలు....!

నీతో గడిపిన ఆ మధుర క్షణాలు

      నా శ్వాసలో అణువణువున నిండి ఉన్నాయి

నీకై పరితపించే నా కన్నులు నిన్నే వెతుకుచున్నాయి

నీ నవ యవ్వన సౌందర్య దర్శనం కోసం

నా మనస్సు ఉవ్విళ్లూరుతుంది

నా అణువణువు నీ స్పర్శకై అలమటిస్తోంది

             ఓ నేస్తమా నీ వెక్కడ ?

ఓ ప్రియ నేస్తమా ఆ నాటి మధురాలు శున్యమా ?    

ఈ నాటి నా కళల  జీవితం అందకారమయమా   ?
నీతో నడిచిన ఆ నాలుగడుగులు నీకై నడవమంటున్నాయి
 
                  నీవు లేని నా జీవితం నిర్జీవం ...!
 
      నీకై వేచిచూసే కన్నులతో ,
 
           నీ ప్రేమకై పరితపించే మనసుతో
                         
                         నీ రాక కోసం నే వేచిచూస్తూ ........