Bu sayfayı gördüm ve neredeyse pes ettim ama sonra PluginSight'ta Craig'den bu article ile karşılaştım. Bu bana IIS'de ASP.NET yerine 401 döndürme fikrini verdi ve bu yüzden IIS'de anonim kimlik doğrulaması etkinleştirildi.
Sorunun çözümü için adımlar aşağıda verilmiştir.
Adım 1: IIS'de Anonim Kimlik Doğrulamayı ve Windows Kimlik Doğrulamasını Etkinleştir.
2. Adım: Global.asax.cs Bu kodu
Kredi/sayesinde:Uploadify (Session and authentication) with ASP.NET MVC
Not: Ben sadece bu kodu istediğiniz beri sadece POST istekleri özel mantığı kullanmak benim versiyonunda uploadify için çalışmak. Başka bir deyişle, GET isteklerinin kodunu siliyorum. GET’i desteklemek istiyorsanız yukarıdaki bağlantıya bir göz atın.
protected void Application_BeginRequest(object sender, EventArgs e)
{
/* we guess at this point session is not already retrieved by application so we recreate cookie with the session id... */
try
{
string session_param_name = "ASPSESSID";
string session_cookie_name = "ASP.NET_SessionId";
if (HttpContext.Current.Request.Form[session_param_name] != null)
{
UpdateCookie(session_cookie_name, HttpContext.Current.Request.Form[session_param_name]);
}
}
catch
{
}
try
{
string auth_param_name = "AUTHID";
string auth_cookie_name = FormsAuthentication.FormsCookieName;
if (HttpContext.Current.Request.Form[auth_param_name] != null)
{
UpdateCookie(auth_cookie_name, HttpContext.Current.Request.Form[auth_param_name]);
return; // this is an uploadify request....get out of here.
}
}
catch
{
}
// handle the windows authentication while keeping anonymous turned on in IIS.
// see: https://stackoverflow.com/questions/2549914/uploadify-flash-file-upload-integrated-windows-authentication
if (Request.ServerVariables["LOGON_USER"].Length == 0) // They haven't provided credentials yet
{
Response.StatusCode = 401;
Response.StatusDescription = "Unauthorized";
Response.End();
return;
}
FormsAuthentication.SetAuthCookie(Request.ServerVariables["LOGON_USER"], true);
}
private void UpdateCookie(string cookie_name, string cookie_value)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies.Get(cookie_name);
if (null == cookie)
{
cookie = new HttpCookie(cookie_name);
}
cookie.Value = cookie_value;
HttpContext.Current.Request.Cookies.Set(cookie);
}
Adım 3: Formun kimlik doğrulama anahtarı ve oturum anahtarını içerecek şekilde Uploadify yürütmesini javascript güncelleyin.
<script>
var auth = "<% = Request.Cookies[FormsAuthentication.FormsCookieName]==null ? string.Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value %>";
var ASPSESSID = "<%= Session.SessionID %>";
$("#uploadifyLogo").uploadify({
...
scriptData: { ASPSESSID: ASPSESSID, AUTHID: auth }
});
Adım 4: güncelleyin web.config
<system.web>
...
<authentication mode="Forms">
<forms defaultUrl="/" />
</authentication>
...
Ben OP gibi aynı sorunu yaşıyorum ve ben çözümünüzü denedim ama işe alınamıyor. Bazı nedenlerden dolayı Request.ServerVariables ["LOGON_USER"] her zaman boş. Baska öneri? – Simon
IIS'de hem anonim kimlik doğrulama hem de windows kimlik doğrulaması etkinleştirilmiş mi? –
Sorulara cevap vermek/soru sormak için geç olduğunu biliyorum, ancak bu, uploadify ve Windows Kimlik Doğrulaması kullanmanın çözümünün Windows Kimlik Doğrulaması'nı KULLANMAMASI gerektirdiği anlamına mı geliyor? – bzarah