私のWebアプリ(進行中の作業)では、新しい顧客が私のWebアプリに登録できるようにしようとしています。ところで、Azureにデプロイしています。
私が取り組んでいるアイデア:
www。[mysite].com/ Register
この登録ページでは、「新規」ユーザーが新しいテナントを登録できます。
customer。[mysite].com/ Register
これは、コードでは次のようになります。
public ActionResult Register()
{
var url = Request.ServerVariables["HTTP_HOST"];
var tenantNameParser = new TenantNameParser(url);
if (!TenantRepository.Exists(tenantNameParser.TenantName))
{
return RedirectToAction("NewCustomer");
}
return View();
}
上記のスニペットでは、テナントが存在するかどうかを確認し、存在しない場合は、新しい顧客にリダイレクトします。
[HttpPost]
public ActionResult NewCustomer(Customer model)
{
if (ModelState.IsValid)
{
var tenant = new Tenant
{
Name = model.TenantName,
Guid = Guid.NewGuid().ToString()
};
TenantRepository.Add(tenant);
// TODO create a new user new tenant repository to do this stuff as 1 atomic action
if (!UserRepository.Exists(model.AccountableEmailAddress))
{
// Attempt to register the user
var createStatus = MembershipService.CreateUser(
model.AccountableUser,
model.Password,
model.AccountableEmailAddress);
if (createStatus == MembershipCreateStatus.Success)
{
FormsService.SignIn(model.AccountableUser, false);
return RedirectToAction("Index", "Home");
}
throw new Exception("crappy implemenation, improve");
}
FormsService.SignIn(model.AccountableUser, false);
// TODO figure out how to redirect to tenant.site.com
return RedirectToAction("Index", "Home");
}
return View(model);
}
上記のコードは新しい顧客を作成し、最終的に私の//todoはこの質問の内容です。実際のテナントをtenant.domain.comの形式で含むURLにリダイレクトするにはどうすればよいですか?
この「テナントの扱い方」が悪いのかどうかはわかりませんが、お気軽にどうぞ。
質問:テナントURL([tenantname。[mysite] .com / Index / Home)にリダイレクトする方法。Redirect( "tenantname"、 "Index"、 "Home")のようなものは素晴らしいでしょうが、もちろん存在しません。私はそれを少しグーグルで検索しましたが、役立つリンクに出くわしませんでした(これが主に私が「間違ったもの」を設計していると思う理由です)。
アドバイスは素晴らしいでしょう!事前にご検討ください。
何を求めているのかわからないために言い換える必要がある場合は、お知らせください。