35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
public partial class sites_test : System.Web.UI.Page
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
string site_id = HttpContext.Current.Request.Url.Host;
|
|
var conn_config = ConfigurationManager.ConnectionStrings[site_id];
|
|
|
|
string title = Sites.sites.FirstOrDefault(q => q.url == site_id)?.title;
|
|
|
|
string conn_str = conn_config==null?"(N/A)": conn_config.ConnectionString;
|
|
int n = 40;
|
|
string conn_str_test = "(N/A)";
|
|
if (conn_str.Length>n)
|
|
{
|
|
conn_str_test=conn_str.Substring(0, n) + "......" + conn_str.Right(n);
|
|
}
|
|
Label1.Text = site_id;
|
|
Label4.Text = conn_str_test;
|
|
}
|
|
}
|
|
public static class StringExtensions
|
|
{
|
|
public static string Right(this string str, int length)
|
|
{
|
|
return str.Substring(str.Length - length, length);
|
|
}
|
|
} |