本文整理汇总了C#中ScriptManager.ResolveClientUrl方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptManager.ResolveClientUrl方法的具体用法?C# ScriptManager.ResolveClientUrl怎么用?C# ScriptManager.ResolveClientUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScriptManager
的用法示例。
在下文中一共展示了ScriptManager.ResolveClientUrl方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateInitializationScript
private static void GenerateInitializationScript(ref StringBuilder sb, HttpContext context, ScriptManager scriptManager, string serviceUrl) {
bool authEnabled = ApplicationServiceHelper.AuthenticationServiceEnabled;
if (authEnabled) {
if (sb == null) {
sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity);
}
// The default path points to the built-in service (if it is enabled)
// Note that the client can't default to this path because it doesn't know what the app root is, we must tell it.
// We must specify the default path to the proxy even if a custom path is provided, because on the client they could
// reset the path back to the default if they want.
string defaultServicePath = scriptManager.ResolveClientUrl("~/" + System.Web.Script.Services.WebServiceData._authenticationServiceFileName);
sb.Append("Sys.Services._AuthenticationService.DefaultWebServicePath = '");
sb.Append(HttpUtility.JavaScriptStringEncode(defaultServicePath));
sb.Append("';\n");
}
bool pathSpecified = !String.IsNullOrEmpty(serviceUrl);
if(pathSpecified) {
if (sb == null) {
sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity);
}
sb.Append("Sys.Services.AuthenticationService.set_path('");
sb.Append(HttpUtility.JavaScriptStringEncode(serviceUrl));
sb.Append("');\n");
}
// only emit this script if (1) the auth webservice is enabled or (2) a custom webservice url is specified
if ((authEnabled || pathSpecified) &&
(context != null && context.Request.IsAuthenticated)) {
Debug.Assert(sb != null);
sb.Append("Sys.Services.AuthenticationService._setAuthenticated(true);\n");
}
}
示例2: GetUrl
public string GetUrl(ScriptManager scriptManager)
{
string url = string.Empty;
if (String.IsNullOrEmpty(Path))
{
try
{
PropertyInfo piScriptManager_IControl = scriptManager.GetType().GetProperty("Control", BindingFlags.NonPublic | BindingFlags.Instance);
MethodInfo miScriptReference_GetUrl = typeof(ScriptReference).GetMethod("GetUrl", BindingFlags.NonPublic | BindingFlags.Instance);
Type typeIControl = Type.GetType(piScriptManager_IControl.PropertyType.AssemblyQualifiedName.ToString(), false, true);
//object value = Convert.ChangeType(piScriptManager_IControl.PropertyType, typeIControl);
object value = piScriptManager_IControl.GetValue(scriptManager, null);
url = (string)miScriptReference_GetUrl.Invoke(this, new object[] { scriptManager, value, false });
/*return base.GetUrl(scriptManager, false); //Ajax 3.5*/
//MethodInfo miGetScriptResourceUrl = typeof(ScriptManager).GetMethod("GetScriptResourceUrl", BindingFlags.NonPublic | BindingFlags.Instance);
//Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
//url = (string)miGetScriptResourceUrl.Invoke(scriptManager, new object[] { Name, asm });
}
catch (Exception ex) { }
}
else
{
url = scriptManager.ResolveClientUrl(Path);
}
return url;
}
示例3: GetUrl
public string GetUrl(ScriptManager scriptManager) {
if (String.IsNullOrEmpty(Path)) {
return base.GetUrl(scriptManager, false);
}
else {
return scriptManager.ResolveClientUrl(Path);
}
}
示例4: ConfigureProfileService
internal static void ConfigureProfileService(ref StringBuilder sb, HttpContext context, ScriptManager scriptManager, List<ScriptManagerProxy> proxies) {
string profileServiceUrl = null;
ArrayList loadedProperties = null;
ProfileServiceManager profileManager;
if(scriptManager.HasProfileServiceManager) {
profileManager = scriptManager.ProfileService;
// get ScriptManager.Path
profileServiceUrl = profileManager.Path.Trim();
if(profileServiceUrl.Length > 0) {
profileServiceUrl = scriptManager.ResolveClientUrl(profileServiceUrl);
}
// get ScriptManager.LoadProperties
if(profileManager.HasLoadProperties) {
loadedProperties = new ArrayList(profileManager._loadProperties);
}
}
// combine proxy Paths (find the first one that has specified one)
// combine loadedProperties collection (take the union of all)
if(proxies != null) {
foreach(ScriptManagerProxy proxy in proxies) {
if(proxy.HasProfileServiceManager) {
profileManager = proxy.ProfileService;
// combine urls
profileServiceUrl = ApplicationServiceManager.MergeServiceUrls(profileManager.Path, profileServiceUrl, proxy);
// combine LoadProperties
if(profileManager.HasLoadProperties) {
if(loadedProperties == null) {
loadedProperties = new ArrayList(profileManager._loadProperties);
}
else {
loadedProperties = ProfileServiceManager.MergeProperties(loadedProperties, profileManager._loadProperties);
}
}
}
}
}
ProfileServiceManager.GenerateInitializationScript(ref sb, context, scriptManager, profileServiceUrl, loadedProperties);
}
示例5: ConfigureRoleService
internal static void ConfigureRoleService(ref StringBuilder sb, HttpContext context, ScriptManager scriptManager, List<ScriptManagerProxy> proxies) {
string roleServiceUrl = null;
bool loadRoles = false;
RoleServiceManager roleManager;
if(scriptManager.HasRoleServiceManager) {
roleManager = scriptManager.RoleService;
// load roles?
loadRoles = roleManager.LoadRoles;
// get ScriptManager.Path
roleServiceUrl = roleManager.Path.Trim();
if(roleServiceUrl.Length > 0) {
roleServiceUrl = scriptManager.ResolveClientUrl(roleServiceUrl);
}
}
// combine proxy ServiceUrls (find the first one that has specified one)
if(proxies != null) {
foreach(ScriptManagerProxy proxy in proxies) {
if(proxy.HasRoleServiceManager) {
roleManager = proxy.RoleService;
// combine load roles
if (roleManager.LoadRoles) {
loadRoles = true;
}
// combine urls
roleServiceUrl = ApplicationServiceManager.MergeServiceUrls(roleManager.Path, roleServiceUrl, proxy);
}
}
}
RoleServiceManager.GenerateInitializationScript(ref sb, context, scriptManager, roleServiceUrl, loadRoles);
}
示例6: GetUrl
protected internal override string GetUrl (ScriptManager scriptManager, bool zip)
{
bool isDebugMode = IsDebugMode (scriptManager);
string path;
string url = String.Empty;
string name = Name;
WebResourceAttribute wra;
// LAMESPEC: Name property takes precedence
if (!String.IsNullOrEmpty (name)) {
Assembly assembly = ResolvedAssembly;
name = GetScriptName (name, isDebugMode, null, assembly, out wra);
path = scriptManager.ScriptPath;
if (IgnoreScriptPath || String.IsNullOrEmpty (path))
url = ScriptResourceHandler.GetResourceUrl (assembly, name, NotifyScriptLoaded);
else {
AssemblyName an = assembly.GetName ();
url = scriptManager.ResolveClientUrl (String.Concat (VirtualPathUtility.AppendTrailingSlash (path), an.Name, '/', an.Version, '/', name));
}
} else if (!String.IsNullOrEmpty ((path = Path))) {
url = GetScriptName (path, isDebugMode, scriptManager.EnableScriptLocalization ? ResourceUICultures : null, null, out wra);
} else {
throw new InvalidOperationException ("Name and Path cannot both be empty.");
}
return url;
}
示例7: GenerateInitializationScript
private static void GenerateInitializationScript(ref StringBuilder sb, HttpContext context, ScriptManager scriptManager, string serviceUrl, bool loadRoles) {
bool enabled = ApplicationServiceHelper.RoleServiceEnabled;
string defaultServicePath = null;
if (enabled) {
if (sb == null) {
sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity);
}
// The default path points to the built-in service (if it is enabled)
// Note that the client can't default to this path because it doesn't know what the app root is, we must tell it.
// We must specify the default path to the proxy even if a custom path is provided, because on the client they could
// reset the path back to the default if they want.
defaultServicePath = scriptManager.ResolveClientUrl("~/" + System.Web.Script.Services.WebServiceData._roleServiceFileName);
sb.Append("Sys.Services._RoleService.DefaultWebServicePath = '");
sb.Append(HttpUtility.JavaScriptStringEncode(defaultServicePath));
sb.Append("';\n");
}
bool pathSpecified = !String.IsNullOrEmpty(serviceUrl);
if (pathSpecified) {
// DevDiv
if (defaultServicePath == null){
defaultServicePath = scriptManager.ResolveClientUrl("~/" + System.Web.Script.Services.WebServiceData._roleServiceFileName);
}
if (loadRoles && !String.Equals(serviceUrl, defaultServicePath, StringComparison.OrdinalIgnoreCase)) {
throw new InvalidOperationException(AtlasWeb.RoleServiceManager_LoadRolesWithNonDefaultPath);
}
if (sb == null) {
sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity);
}
sb.Append("Sys.Services.RoleService.set_path('");
sb.Append(HttpUtility.JavaScriptStringEncode(serviceUrl));
sb.Append("');\n");
}
// Dev10 757178: Do not attempt during design mode. This code isn't important for intellisense anyway.
if (loadRoles) {
if (scriptManager.DesignMode) {
// Dev10 757178: Do not lookup user roles at design time.
// But at DesignTime this method is only important because if it produces any init script,
// it prompts AddFrameworkScripts to add the MicrosoftAjaxApplicationServices.js script reference.
// So just append a comment to ensure at least some script is generated.
if (sb == null) {
sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity);
}
sb.Append("// loadRoles\n");
}
else {
string[] roles = Roles.GetRolesForUser();
if(roles != null && roles.Length > 0) {
if (sb == null) {
sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity);
}
sb.Append("Sys.Services.RoleService._roles = ");
sb.Append(new JavaScriptSerializer().Serialize(roles, JavaScriptSerializer.SerializationFormat.JavaScript));
sb.Append(";\n");
}
}
}
}
示例8: GenerateInitializationScript
private static void GenerateInitializationScript(ref StringBuilder sb, HttpContext context, ScriptManager scriptManager, string serviceUrl, ArrayList loadedProperties) {
string defaultServicePath = null;
bool loadProperties = loadedProperties != null && loadedProperties.Count > 0;
if (ApplicationServiceHelper.ProfileServiceEnabled) {
if (sb == null) {
sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity);
}
// The default path points to the built-in service (if it is enabled)
// Note that the client can't default to this path because it doesn't know what the app root is, we must tell it.
// We must specify the default path to the proxy even if a custom path is provided, because on the client they could
// reset the path back to the default if they want.
defaultServicePath = scriptManager.ResolveClientUrl("~/" + System.Web.Script.Services.WebServiceData._profileServiceFileName);
sb.Append("Sys.Services._ProfileService.DefaultWebServicePath = '");
sb.Append(HttpUtility.JavaScriptStringEncode(defaultServicePath));
sb.Append("';\n");
}
if (!String.IsNullOrEmpty(serviceUrl)) {
// DevDiv Bug 72257:When custom path is set and loadProperties=True, we shouldn't use the default path
// loadProperties script always retrieves the properties from default profile provider, which is not correct if ProfileService
// points to non default path. Hence throw when non default path and loadProperties both are specified.
if (defaultServicePath == null){
defaultServicePath = scriptManager.ResolveClientUrl("~/" + System.Web.Script.Services.WebServiceData._profileServiceFileName);
}
if (loadProperties && !String.Equals(serviceUrl, defaultServicePath, StringComparison.OrdinalIgnoreCase)) {
throw new InvalidOperationException(AtlasWeb.ProfileServiceManager_LoadProperitesWithNonDefaultPath);
}
if (sb == null) {
sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity);
}
sb.Append("Sys.Services.ProfileService.set_path('");
sb.Append(HttpUtility.JavaScriptStringEncode(serviceUrl));
sb.Append("');\n");
}
if (loadProperties) {
if (sb == null) {
sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity);
}
if (scriptManager.DesignMode) {
// Dev10 757178: context is null at design time, so we cannot access ProfileBase.
// But at DesignTime this method is only important because if it produces any init script,
// it prompts AddFrameworkScripts to add the MicrosoftAjaxApplicationServices.js script reference.
// So just append a comment to ensure at least some script is generated.
sb.Append("// loadProperties\n");
}
else if (context != null) {
// get values for all properties to be pre-loaded.
// GetSettingsProperty puts each property into either the top level settings dictionary or if its part of a group,
// it creates an entry for the group in the group collection and puts the setting in the dictionary for the group.
SortedList<string, object> topLevelSettings = new SortedList<string, object>(loadedProperties.Count);
SortedList<string, SortedList<string, object>> profileGroups = null;
ProfileBase profile = context.Profile;
foreach(string propertyFullName in loadedProperties) {
GetSettingsProperty(profile, propertyFullName, topLevelSettings, ref profileGroups, /* ensure exists */ true);
}
RenderProfileProperties(sb, topLevelSettings, profileGroups);
}
}
}
示例9: GetResourceUrl
public string GetResourceUrl()
{
var scriptManager = new ScriptManager();
try
{
return this.GetUrl(scriptManager, zip: false);
}
catch (NullReferenceException ex)
{
////This is because ScriptReference.ClientUrlResolver is null as the class in to initialize on the page.
if (this.IsGetUrlFromPathException(ex))
{
return scriptManager.ResolveClientUrl(this.Path);
}
throw;
}
}
示例10: GetUrl
protected internal override string GetUrl (ScriptManager scriptManager, bool zip)
{
bool isDebugMode = scriptManager.IsDeploymentRetail ? false :
(ScriptModeInternal == ScriptMode.Inherit ? scriptManager.IsDebuggingEnabled : (ScriptModeInternal == ScriptMode.Debug));
string path = Path;
string url = String.Empty;
if (!String.IsNullOrEmpty (path)) {
url = GetScriptName (path, isDebugMode, scriptManager.EnableScriptLocalization ? ResourceUICultures : null);
} else if (!String.IsNullOrEmpty (Name)) {
Assembly assembly;
string assemblyName = this.Assembly;
if (String.IsNullOrEmpty (assemblyName))
assembly = typeof (ScriptManager).Assembly;
else
assembly = global::System.Reflection.Assembly.Load (assemblyName);
string name = GetScriptName (Name, isDebugMode, null);
string scriptPath = scriptManager.ScriptPath;
if (IgnoreScriptPath || String.IsNullOrEmpty (scriptPath))
url = ScriptResourceHandler.GetResourceUrl (assembly, name, NotifyScriptLoaded);
else {
AssemblyName an = assembly.GetName ();
url = scriptManager.ResolveClientUrl (String.Concat (VirtualPathUtility.AppendTrailingSlash (scriptPath), an.Name, '/', an.Version, '/', name));
}
} else {
throw new InvalidOperationException ("Name and Path cannot both be empty.");
}
return url;
}