using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Optimization;
namespace xxxxxxxxx
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
//RouteTable.Routes.MapMvcAttributeRoutes();
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
}
void Application_BeginRequest(object sender, EventArgs e)
{
//string acceptTypes = Request.Headers["Accept"];
//if (!string.IsNullOrEmpty(acceptTypes) && acceptTypes.ToLower().IndexOf("text/vnd.wap.wml") > -1)
//{
// Response.Cache.SetCacheability(HttpCacheability.NoCache);
//}
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]);
}
else if (HttpContext.Current.Request.QueryString[session_param_name] != null)
{
UpdateCookie(session_cookie_name, HttpContext.Current.Request.QueryString[session_param_name]);
}
}
catch (Exception exc)
{
HttpContext.Current.Response.Write(exc.Message);
}
try
{
string auth_param_name = "AUTHID";
string auth_cookie_name = System.Web.Security.FormsAuthentication.FormsCookieName;
if (HttpContext.Current.Request.Form[auth_param_name] != null)
{
UpdateCookie(auth_cookie_name, HttpContext.Current.Request.Form[auth_param_name]);
}
else if (HttpContext.Current.Request.QueryString[auth_param_name] != null)
{
UpdateCookie(auth_cookie_name, HttpContext.Current.Request.QueryString[auth_param_name]);
}
}
catch (Exception exc)
{
HttpContext.Current.Response.Write(exc.Message);
}
}
void UpdateCookie(string cookie_name, string cookie_value)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies.Get(cookie_name);
if (cookie == null)
{
HttpCookie cookie1 = new HttpCookie(cookie_name, cookie_value);
Response.Cookies.Add(cookie1);
}
else
{
cookie.Value = cookie_value;
HttpContext.Current.Request.Cookies.Set(cookie);
}
}
}
}
var auth = "@(Request.Cookies[FormsAuthentication.FormsCookieName]==null ? string.Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value)";
var ASPSESSID = "@(Session.SessionID)";
$("#file_upload").uploadify({
swf: '@Url.Content("~/Scripts/uploadify/uploadify.swf")',
uploader: '@Url.Action("Image", "Upload", new { w=300})' + '&ASPSESSID=' + ASPSESSID + '&AUTHID=' + auth,
auto: true,
multi: false,
buttonImage: '/content/user/image/upload.gif',
height: 27,
width: 94,
fileTypeDesc: 'Image Files',
fileTypeExts: '*.gif; *.jpg; *.png',
onUploadSuccess: function (file, data, response) {
var d = JSON.parse(data)
if (d.s == 1) {
UploadPhotoAPI(d.url, '')
}
}
});