Skip to content

Instantly share code, notes, and snippets.

View explorer14's full-sized avatar

Aman Agrawal explorer14

View GitHub Profile
using DataAccess;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace WebApplication_MultiTenant.CustomMiddleware
{
<rewrite>
<rules>
<rule name="ReverseProxyRule2"
enabled="true" stopProcessing="true">
<match url="^Contact" />
<action type="Rewrite" url="http://localhost:8021/Home/Contact" />
</rule>
</rules>
</rewrite>
<rewrite>
<globalRules>
<rule name="ReverseProxyRule1"
enabled="true" stopProcessing="true">
<match url="^Contact" />
<action type="Rewrite" url="http://localhost:8021/Home/Contact" />
<conditions>
<add input="{SERVER_PORT}" pattern="88" />
</conditions>
</rule>
<rule name="LinkNScriptFixer" preCondition="IsHTML"
enabled="true" stopProcessing="true">
<match filterByTags="Link, Script" pattern="^/(css|js)/(.*)"
negate="false" />
<action type="Rewrite" value="http://localhost:8021{R:0}" />
</rule>
<rule name="FormActionFixer" preCondition="IsHTML"
enabled="true" stopProcessing="true">
<match filterByTags="Form" pattern="^/(.*)/(.*)" />
<action type="Rewrite" value="/{R:2}" />
<rule name="FormSubmitter" enabled="true"
stopProcessing="true">
<match url="^Submit" />
<action type="Rewrite"
url="http://localhost:8021/Home/Submit" />
</rule>
<rule name="ResponseLocationFixer"
preCondition="IsRedirection"
enabled="true" stopProcessing="true">
<match serverVariable="RESPONSE_LOCATION" pattern="^/(.*)/(.*)" />
<action type="Rewrite" value="/{R:2}" />
</rule>
<preConditions>
<preCondition name="IsRedirection">
<add input="{RESPONSE_STATUS}" pattern="3\d\d" />
</preCondition>
public class Global : HttpApplication
{
private void Application_Start(object sender, EventArgs e)
{
// Register application level routes here.
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
public static class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
var settings = new FriendlyUrlSettings();
settings.AutoRedirectMode = RedirectMode.Temporary;
routes.EnableFriendlyUrls(settings);
}
}
public class HomeController : Controller
{
public IActionResult Contact()
{
ViewData["Message"] = "Your contact page.";
return View();
}
[HttpPost]