Default.aspx adında bir dosya oluşturdum. Ve içerisine şunu yazdım:
<%@ Page Language="C#" Debug="true" codePage="28599" AutoEventWireup="false" codeFile="default.aspx.cs" Inherits="dene_aspx"%>
Bir de default.aspx.cs adında bir dosya oluşturup şu kodları yazdım:
public class SubdomainModule : IHttpModule
{
public void Init(HttpApplication app)
{
// register for pipeline events
app.BeginRequest += new EventHandler(this.OnBeginRequest);
}
public void Dispose() {}
public void OnBeginRequest(object o, EventArgs args)
{
// get access to app and context
HttpApplication app = (HttpApplication)o;
HttpContext ctx = app.Context;
if (!(app.Context.Request.Url.Host.StartsWith("codebe tter") || app.Context.Request.Url.Host.StartsWith("www")))
{
if (ctx.Request.Path.ToUpper() == "/DEFAULT.ASPX")
{
string[] domainParts = app.Context.Request.Url.Host.Split(".".ToCharArray ());
if (domainParts.Length > 2)
ctx.Server.Transfer("/explore/explore.aspx?q=" + domainParts[0]);
}
}
}
}
sonra bir de web.config adında bir dosya oluşturup şu kodları yazdım:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<customErrors mode="Off"/>
<globalization requestEncoding="iso-8859-9" responseEncoding="iso-8859-9" culture="tr-TR" uiCulture="tr" fileEncoding="iso-8859-9"></globalization>
<pages validateRequest="false"
enableEventValidation="false" enableViewStateMac="false"
viewStateEncryptionMode="Never"> </pages>
</system.web>
<httpModules>
<add name="SubdomainModule" type="Tompkins.Cs.Subdomains.SubdomainModule, Tompkins.Cs.SubdomainHandler" />
</httpModules>
</configuration>
Ama şöyle bir hata mesajıyla karşılaştım:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Herkesin çok kolay dediği bu sınırsız sub domain açma olayını bir türlü çözemiyorum