현재 활성 거주자를 기반으로보기를 반환하려하지만 작동하지 않습니다. 어떤 이유로 테넌트 사이트의 이름을 포함해야하더라도 이름은 비어 있습니다. 여기 내 코드는 다음과 같습니다.Orchard CMS의 ShellSettings를 사용하여 현재/활성 거주자 이름 가져 오기
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Orchard.Themes;
using Orchard.Environment.Configuration;
namespace Speedbump.Controllers
{
public class SpeedBumpController : Controller
{
[Themed]
public ActionResult Index(ShellSettings settings)
{
//Initialize Variables
string requestedURL = "";
string finalRequestedURL = "";
bool wasValidURL = false;
//Grab the query string parameters and put them into variables to be used later
//Requested URL
requestedURL = Request.QueryString["url"];
//Remove "http://" or "https://" from the Requested URL (if it exists)
if (requestedURL.IndexOf("http") > -1)
{
finalRequestedURL = requestedURL.Replace("http://", "");
}
else if (requestedURL.IndexOf("https") > -1)
{
finalRequestedURL = requestedURL.Replace("https://", "");
}
else
{
finalRequestedURL = requestedURL;
}
//Create a list of strings to contain all the "valid" URLs
var whiteList = new List<string>();
//Add URLs to the list
whiteList.Add("www.google.com");
whiteList.Add("www.gmail.com");
//Loop through each URL in the list of Valid URLs checking against the finalRequestedURL
foreach (string validURL in whiteList)
{
if (finalRequestedURL == validURL)
{
wasValidURL = true;
break;
}
wasValidURL = false;
}
//ViewBag Items
ViewBag.wasValidURL = wasValidURL;
ViewBag.requestedURL = finalRequestedURL;
ViewBag.tenantName = settings.Name;
//Return a different view depending on whether or not the url is valid
if (wasValidURL)
{
if (!string.IsNullOrEmpty(settings.Name))
{
return View(settings.Name + "ValidURL");
}
else
{
return View("ValidURL");
}
}
else
{
if (!string.IsNullOrEmpty(settings.Name))
{
return View(settings.Name + "InvalidURL");
}
else
{
return View("InvalidURL");
}
}
}
}
}
어떤 도움을 주시면 감사하겠습니다. 고맙습니다.
@ Bertrand Le Roy 도움을 주셔서 감사합니다. 저를위한 몇 가지 것을 명확히 해 주시겠습니까? 화이트리스트를 구성 가능하게 만들려면 어떻게해야합니까? 나는 더 나은 선택으로 그것을하고 있었지만 그것을 달성하는 방법을 생각할 수 없었다. 또한 querystring에 액세스하는 대신 "action parameters"를 사용하는 방법은 무엇입니까? 모든 도움을 주셔서 다시 한 번 감사드립니다. – EmeraldArcher
죄송합니다. SiteSettings 콘텐트 부분에 새 콘텐트를 추가하면 관리 사용자가 허용 목록에 들어가는 URL 수를 입력하고 사이트 이름에 액세스하는 것과 같은 방법으로 허용 목록에 액세스 할 수 있습니까? – EmeraldArcher
구성 가능하도록 설정 : 사이트 설정을 지정합니다 (단, 알아 냈습니다.). 액션 매개 변수 : 액션에'string url' 매개 변수가 있습니다. –