本文整理汇总了C#中DotNetNuke.Entities.Portals.PortalAliasController.GetPortalAlias方法的典型用法代码示例。如果您正苦于以下问题:C# PortalAliasController.GetPortalAlias方法的具体用法?C# PortalAliasController.GetPortalAlias怎么用?C# PortalAliasController.GetPortalAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Entities.Portals.PortalAliasController
的用法示例。
在下文中一共展示了PortalAliasController.GetPortalAlias方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestFixtureSetUp
public override void TestFixtureSetUp()
{
base.TestFixtureSetUp();
var tc = new TabController();
var tab = tc.GetTabByName(_aboutUsPageName, PortalId);
_tabId = tab.TabID;
//Add Portal Aliases
var aliasController = new PortalAliasController();
TestUtil.ReadStream(String.Format("{0}", "Aliases"), (line, header) =>
{
string[] fields = line.Split(',');
var alias = aliasController.GetPortalAlias(fields[0], PortalId);
if (alias == null)
{
alias = new PortalAliasInfo
{
HTTPAlias = fields[0],
PortalID = PortalId
};
TestablePortalAliasController.Instance.AddPortalAlias(alias);
}
});
TestUtil.ReadStream(String.Format("{0}", "Users"), (line, header) =>
{
string[] fields = line.Split(',');
TestUtil.AddUser(PortalId, fields[0].Trim(), fields[1].Trim(), fields[2].Trim());
});
}
示例2: TestFixtureTearDown
public override void TestFixtureTearDown()
{
base.TestFixtureTearDown();
var aliasController = new PortalAliasController();
TestUtil.ReadStream(String.Format("{0}", "Aliases"), (line, header) =>
{
string[] fields = line.Split(',');
var alias = aliasController.GetPortalAlias(fields[0], PortalId);
TestablePortalAliasController.Instance.DeletePortalAlias(alias);
});
TestUtil.ReadStream(String.Format("{0}", "Users"), (line, header) =>
{
string[] fields = line.Split(',');
TestUtil.DeleteUser(PortalId, fields[0]);
});
}
示例3: Handle404OrException
private static void Handle404OrException(FriendlyUrlSettings settings, HttpContext context, Exception ex, UrlAction result, bool transfer, bool showDebug)
{
//handle Auto-Add Alias
if (result.Action == ActionType.Output404 && CanAutoAddPortalAlias())
{
//Need to determine if this is a real 404 or a possible new alias.
var portalId = Host.Host.HostPortalID;
if (portalId > Null.NullInteger)
{
//Get all the existing aliases
var aliases = TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(portalId).ToList();
bool autoaddAlias;
bool isPrimary = false;
if (!aliases.Any())
{
autoaddAlias = true;
isPrimary = true;
}
else
{
autoaddAlias = true;
foreach (var alias in aliases)
{
if (result.DomainName.ToLowerInvariant().IndexOf(alias.HTTPAlias, StringComparison.Ordinal) == 0
&& result.DomainName.Length >= alias.HTTPAlias.Length)
{
autoaddAlias = false;
break;
}
}
}
if (autoaddAlias)
{
var portalAliasInfo = new PortalAliasInfo
{
PortalID = portalId,
HTTPAlias = result.RewritePath,
IsPrimary = isPrimary
};
TestablePortalAliasController.Instance.AddPortalAlias(portalAliasInfo);
context.Response.Redirect(context.Request.Url.ToString(), true);
}
}
}
if (context != null)
{
HttpRequest request = context.Request;
HttpResponse response = context.Response;
HttpServerUtility server = context.Server;
const string errorPageHtmlHeader = @"<html><head><title>{0}</title></head><body>";
const string errorPageHtmlFooter = @"</body></html>";
var errorPageHtml = new StringWriter();
CustomErrorsSection ceSection = null;
//876 : security catch for custom error reading
try
{
ceSection = (CustomErrorsSection) WebConfigurationManager.GetSection("system.web/customErrors");
}
// ReSharper disable EmptyGeneralCatchClause
catch (Exception)
// ReSharper restore EmptyGeneralCatchClause
{
//on some medium trust environments, this will throw an exception for trying to read the custom Errors
//do nothing
}
/* 454 new 404/500 error handling routine */
bool useDNNTab = false;
int errTabId = -1;
string errUrl = null;
string status = "";
bool isPostback = false;
if (settings != null)
{
if (request.RequestType == "POST")
{
isPostback = true;
}
if (result != null && ex != null)
{
result.DebugMessages.Add("Exception: " + ex.Message);
result.DebugMessages.Add("Stack Trace: " + ex.StackTrace);
if (ex.InnerException != null)
{
result.DebugMessages.Add("Inner Ex : " + ex.InnerException.Message);
result.DebugMessages.Add("Stack Trace: " + ex.InnerException.StackTrace);
}
else
{
result.DebugMessages.Add("Inner Ex : null");
}
}
string errRH;
string errRV;
//.........这里部分代码省略.........
示例4: IdentifyPortalAlias
private void IdentifyPortalAlias(HttpContext context,
HttpRequest request,
Uri requestUri, UrlAction result,
NameValueCollection queryStringCol,
FriendlyUrlSettings settings,
Guid parentTraceId)
{
//get the domain name of the request, if it isn't already supplied
if (request != null && string.IsNullOrEmpty(result.DomainName))
{
result.DomainName = Globals.GetDomainName(request); //parse the domain name out of the request
}
// get tabId from querystring ( this is mandatory for maintaining portal context for child portals )
if (queryStringCol["tabid"] != null)
{
string raw = queryStringCol["tabid"];
int tabId;
if (Int32.TryParse(raw, out tabId))
{
result.TabId = tabId;
}
else
{
//couldn't parse tab id
//split in two?
string[] tabids = raw.Split(',');
if (tabids.GetUpperBound(0) > 0)
{
//hmm more than one tabid
if (Int32.TryParse(tabids[0], out tabId))
{
result.TabId = tabId;
//but we want to warn against this!
var ex =
new Exception(
"Illegal request exception : Two TabId parameters provided in a single request: " +
requestUri);
UrlRewriterUtils.LogExceptionInRequest(ex, "Not Set", result);
result.Ex = ex;
}
else
{
//yeah, nothing, divert to 404
result.Action = ActionType.Output404;
var ex =
new Exception(
"Illegal request exception : TabId parameters in query string, but invalid TabId requested : " +
requestUri);
UrlRewriterUtils.LogExceptionInRequest(ex, "Not Set", result);
result.Ex = ex;
}
}
}
}
// get PortalId from querystring ( this is used for host menu options as well as child portal navigation )
if (queryStringCol["portalid"] != null)
{
string raw = queryStringCol["portalid"];
int portalId;
if (Int32.TryParse(raw, out portalId))
{
//848 : if portal already found is different to portal id in querystring, then load up different alias
//this is so the portal settings will be loaded correctly.
if (result.PortalId != portalId)
{
//portal id different to what we expected
result.PortalId = portalId;
//check the loaded portal alias, because it might be wrong
if (result.PortalAlias != null && result.PortalAlias.PortalID != portalId)
{
//yes, the identified portal alias is wrong. Find the correct alias for this portal
PortalAliasInfo pa = TabIndexController.GetPortalAliasByPortal(portalId, result.DomainName);
if (pa != null)
{
//note: sets portal id and portal alias
result.PortalAlias = pa;
}
}
}
}
}
else
{
//check for a portal alias if there's no portal Id in the query string
//check for absence of captcha value, because the captcha string re-uses the alias querystring value
if (queryStringCol["alias"] != null && queryStringCol["captcha"] == null)
{
string alias = queryStringCol["alias"];
PortalAliasInfo portalAlias = PortalAliasController.GetPortalAliasInfo(alias);
if (portalAlias != null)
{
//ok the portal alias was found by the alias name
// check if the alias contains the domain name
if (alias.Contains(result.DomainName) == false)
{
// replaced to the domain defined in the alias
if (request != null)
{
//.........这里部分代码省略.........
示例5: AddPortalAlias
protected string AddPortalAlias(string portalAlias, int portalID)
{
if (!String.IsNullOrEmpty(portalAlias))
{
if (portalAlias.IndexOf("://") != -1)
{
portalAlias = portalAlias.Remove(0, portalAlias.IndexOf("://") + 3);
}
var objPortalAliasController = new PortalAliasController();
var objPortalAlias = objPortalAliasController.GetPortalAlias(portalAlias, portalID);
if (objPortalAlias == null)
{
objPortalAlias = new PortalAliasInfo { PortalID = portalID, HTTPAlias = portalAlias };
objPortalAliasController.AddPortalAlias(objPortalAlias);
}
}
return portalAlias;
}
示例6: GetAliasForPortal
private static PortalAliasInfo GetAliasForPortal(string httpAlias, int portalId, ref List<string> messages)
{
//if no match found, then call database to find (don't rely on cache for this one, because it is an exception event, not an expected event)
var pac = new PortalAliasController();
PortalAliasInfo alias = pac.GetPortalAlias(httpAlias, portalId);
if (alias == null)
{
//no match between alias and portal id
var aliasArray = TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(portalId).ToList();
if (aliasArray.Count > 0)
{
alias = aliasArray[0]; //nab the first one here
messages.Add("Portal Id " + portalId.ToString() + " does not match http alias " + httpAlias +
" - " + alias.HTTPAlias + " was used instead");
}
else
{
messages.Add("Portal Id " + portalId.ToString() +
" does not match http alias and no usable alias could be found");
}
}
return alias;
}
示例7: FriendlyUrlInternal
private string FriendlyUrlInternal(TabInfo tab, string path, string pageName, string portalAlias, PortalSettings portalSettings)
{
Guid parentTraceId = Guid.Empty;
int portalId = (portalSettings != null) ? portalSettings.PortalId : tab.PortalID;
bool cultureSpecificAlias;
var localSettings = Settings;
//Call GetFriendlyAlias to get the Alias part of the url
if (String.IsNullOrEmpty(portalAlias) && portalSettings != null)
{
portalAlias = portalSettings.PortalAlias.HTTPAlias;
}
string friendlyPath = GetFriendlyAlias(path,
ref portalAlias,
portalId,
localSettings,
portalSettings,
out cultureSpecificAlias);
if (portalSettings != null)
{
CheckAndUpdatePortalSettingsForNewAlias(portalSettings, cultureSpecificAlias, portalAlias);
}
if (tab == null && path == "~/" && String.Compare(pageName, Globals.glbDefaultPage, StringComparison.OrdinalIgnoreCase) == 0)
{
//this is a request for the site root for he dnn logo skin object (642)
//do nothing, the friendly alias is already correct - we don't want to append 'default.aspx' on the end
}
else
{
//Get friendly path gets the standard dnn-style friendly path
friendlyPath = GetFriendlyQueryString(tab, friendlyPath, pageName, localSettings);
if (portalSettings == null)
{
var pac = new PortalAliasController();
PortalAliasInfo alias = pac.GetPortalAlias(portalAlias, tab.PortalID);
portalSettings = new PortalSettings(tab.TabID, alias);
}
//ImproveFriendlyUrl will attempt to remove tabid/nn and other information from the Url
friendlyPath = ImproveFriendlyUrl(tab,
friendlyPath,
pageName,
portalSettings,
false,
cultureSpecificAlias,
localSettings,
parentTraceId);
}
//set it to lower case if so allowed by settings
friendlyPath = ForceLowerCaseIfAllowed(tab, friendlyPath, localSettings);
return friendlyPath;
}
示例8: CheckAndUpdatePortalSettingsForNewAlias
private static void CheckAndUpdatePortalSettingsForNewAlias(PortalSettings portalSettings, bool cultureSpecificAlias, string portalAlias)
{
if (cultureSpecificAlias && portalAlias != portalSettings.PortalAlias.HTTPAlias)
{
//was a change in alias, need to update the portalSettings with a new portal alias
var pac = new PortalAliasController();
PortalAliasInfo pa = pac.GetPortalAlias(portalAlias, portalSettings.PortalId);
if (pa != null)
{
portalSettings.PortalAlias = pa;
}
}
}
示例9: AddPortalAlias
/// <summary>
/// Creates a new portal alias
/// </summary>
/// <param name="PortalId">Id of the portal</param>
/// <param name="PortalAlias">Portal Alias to be created</param>
/// <history>
/// [cnurse] 01/11/2005 created
/// </history>
public void AddPortalAlias( int PortalId, string PortalAlias )
{
PortalAliasController objPortalAliasController = new PortalAliasController();
//Check if the Alias exists
PortalAliasInfo objPortalAliasInfo = objPortalAliasController.GetPortalAlias( PortalAlias, PortalId );
//If alias does not exist add new
if( objPortalAliasInfo == null )
{
objPortalAliasInfo = new PortalAliasInfo();
objPortalAliasInfo.PortalID = PortalId;
objPortalAliasInfo.HTTPAlias = PortalAlias;
objPortalAliasController.AddPortalAlias( objPortalAliasInfo );
}
}
示例10: AddPortalAlias
/// -----------------------------------------------------------------------------
/// <summary>
/// Creates a new portal alias
/// </summary>
/// <param name="portalId">Id of the portal</param>
/// <param name="portalAlias">Portal Alias to be created</param>
/// <remarks>
/// </remarks>
/// <history>
/// [cnurse] 01/11/2005 created
/// </history>
/// -----------------------------------------------------------------------------
public void AddPortalAlias(int portalId, string portalAlias)
{
var portalAliasController = new PortalAliasController();
//Check if the Alias exists
PortalAliasInfo portalAliasInfo = portalAliasController.GetPortalAlias(portalAlias, portalId);
//If alias does not exist add new
if (portalAliasInfo == null)
{
portalAliasInfo = new PortalAliasInfo {PortalID = portalId, HTTPAlias = portalAlias, IsPrimary = true};
TestablePortalAliasController.Instance.AddPortalAlias(portalAliasInfo);
}
}
示例11: cmdUpdate_Click
/// <summary>
/// cmdUpdate_Click runs when the Update button is clicked
/// </summary>
/// <history>
/// [cnurse] 01/17/2005 documented
/// </history>
protected void cmdUpdate_Click( Object sender, EventArgs e )
{
try
{
string strAlias = txtAlias.Text;
if( !String.IsNullOrEmpty(strAlias) )
{
if( strAlias.IndexOf( "://" ) != - 1 )
{
strAlias = strAlias.Remove( 0, strAlias.IndexOf( "://" ) + 3 );
}
if( strAlias.IndexOf( "\\\\" ) != - 1 )
{
strAlias = strAlias.Remove( 0, strAlias.IndexOf( "\\\\" ) + 2 );
}
PortalAliasController p = new PortalAliasController();
if( ViewState["PortalAliasID"] != null )
{
PortalAliasInfo objPortalAliasInfo = new PortalAliasInfo();
objPortalAliasInfo.PortalAliasID = Convert.ToInt32( ViewState["PortalAliasID"] );
objPortalAliasInfo.PortalID = Convert.ToInt32( ViewState["PortalID"] );
objPortalAliasInfo.HTTPAlias = strAlias;
try
{
p.UpdatePortalAliasInfo(objPortalAliasInfo);
}
catch
{
UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("DuplicateAlias", this.LocalResourceFile), ModuleMessageType.RedError);
return;
}
}
else
{
PortalAliasInfo objPortalAliasInfo;
objPortalAliasInfo = p.GetPortalAlias( strAlias, Convert.ToInt32( ViewState["PortalAliasID"] ) );
if( objPortalAliasInfo == null )
{
objPortalAliasInfo = new PortalAliasInfo();
objPortalAliasInfo.PortalID = Convert.ToInt32( ViewState["PortalID"] );
objPortalAliasInfo.HTTPAlias = strAlias;
p.AddPortalAlias( objPortalAliasInfo );
}
else
{
UI.Skins.Skin.AddModuleMessage( this, Localization.GetString( "DuplicateAlias", this.LocalResourceFile ), ModuleMessageType.RedError );
return;
}
}
UI.Skins.Skin.AddModuleMessage( this, Localization.GetString( "Success", this.LocalResourceFile ), ModuleMessageType.GreenSuccess );
Response.Redirect( Convert.ToString( ViewState["UrlReferrer"] ), true );
}
}
catch( Exception exc ) //Module failed to load
{
Exceptions.ProcessModuleLoadException( this, exc );
}
}
示例12: AddPortalAlias
/// -----------------------------------------------------------------------------
/// <summary>
/// Creates a new portal alias
/// </summary>
/// <param name="portalId">Id of the portal</param>
/// <param name="portalAlias">Portal Alias to be created</param>
/// <remarks>
/// </remarks>
/// <history>
/// [cnurse] 01/11/2005 created
/// </history>
/// -----------------------------------------------------------------------------
public void AddPortalAlias(int portalId, string portalAlias)
{
PortalAliasController portalAliasController = new PortalAliasController();
//Check if the Alias exists
PortalAliasInfo portalAliasInfo = portalAliasController.GetPortalAlias(portalAlias, portalId);
//If alias does not exist add new
if (portalAliasInfo == null)
{
portalAliasInfo = new PortalAliasInfo();
portalAliasInfo.PortalID = portalId;
portalAliasInfo.HTTPAlias = portalAlias;
portalAliasController.AddPortalAlias(portalAliasInfo);
}
}