ApplicationCollection.InvalidApplicationPathCharacters Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieves an array of characters that cannot be used in the path of an application.
public:
static cli::array <char> ^ InvalidApplicationPathCharacters();
public static char[] InvalidApplicationPathCharacters ();
static member InvalidApplicationPathCharacters : unit -> char[]
Public Shared Function InvalidApplicationPathCharacters () As Char()
Returns
An array of characters that cannot be used in the path of an application.
Examples
The following example demonstrates how to use the InvalidApplicationPathCharacters method to validate application paths.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;
using Microsoft.Web.Management;
namespace AdministrationSnippets
{
public class AdministrationApplicationCollectionInvalidApplicationPathCharacters
{
// Determines if the paths provided are valid application paths
public void ValidateApplicationPathCharacters()
{
string[] paths = { "\\Blog", "/Blog", "/Blog?", ":/Blog" };
foreach (string path in paths)
{
Console.WriteLine("{0} is {1}", path,
IsValidApplicationPath(path) ? "valid" : "invalid");
}
}
// Validates applicationpath characters before adding an application
public bool IsValidApplicationPath(string path)
{
return (path.IndexOfAny(
ApplicationCollection.InvalidApplicationPathCharacters()) == -1);
}
}
}
Remarks
In a Windows operating system that is running the common language runtime (CLR), this method will return the following characters: \?;:@&=+$,|"<>*
"*" is an invalid file system character. You cannot use the remaining characters in managed-code location tags. The "/" character is acceptable for a virtual directory.