首页 技术 正文
技术 2022年11月15日
0 收藏 505 点赞 2,896 浏览 3163 个字

CSHTML代码

 @{
if (Request.Cookies[FormsAuthentication.FormsCookieName] != null)
{
<input type="hidden" id="cookieVal" name="cookieVal" value="@Request.Cookies[FormsAuthentication.FormsCookieName].Value" />;
}
} <script type="text/javascript">
$(function () {
var auth = $("#cookieVal").val() || "";
$("#uploadify").uploadify({
'swf': '../../Content/uploadify/uploadify.swf',
'uploader': "/LawInfo/Uploadify",
'cancelImg': '../../Content/uploadify/cancel.png',
'folder': '../../File/uploadLaw',
'queueID': 'fileQueue',
'buttonText': "浏览",
'fileTypeExts': '*.doc;*.docx;*.pdf;*.xls;*.xlsx;*.txt;*.ppt;*.pptx',
'auto': false,
'formData': { 'AUTHID': auth, 'ASPSESSID': '@Session.SessionID' },
'fileSizeLimit': 10485760,
'removeTimeout': 1,
'multi': false,
'onSelect': function () {
$("#fileQueue").show();
//$("#_dialog").show();
},
'onUploadSuccess': function (file, data, response) {
var jsonres = JSON.parse(data);
$("#previewdiv").show();
//$("#Icon").val(jsonres.filename);//为隐藏域赋值
//filepath,filename
$("#LawFileName").html(file.name);
$("#LawFilePath").val(jsonres.filepath);
$("#LawFileName").attr("href", jsonres.filepath)
$("#fileQueue").hide();
},
'onUploadError': function (file, errorCode, errorMsg, errorString) {
var msgText = "上传失败\n";
switch (errorCode) {
case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
msgText += "HTTP 错误\n" + errorMsg;
break;
case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
msgText += "上传文件丢失,请重新上传";
break;
case SWFUpload.UPLOAD_ERROR.IO_ERROR:
msgText += "IO错误";
break;
case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
msgText += "安全性错误\n" + errorMsg;
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
msgText += "每次最多上传 " + this.settings.uploadLimit + "个";
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
msgText += errorMsg;
break;
case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:
msgText += "找不到指定文件,请重新操作";
break;
case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
msgText += "参数错误";
break;
default:
msgText += "文件:" + file.name + "\n错误码:" + errorCode + "\n"
+ errorMsg + "\n" + errorString;
}
iTools.showError("文件:" + file.name + msgText);
}
}); });
</script>

C#代码

在Global.asax中添加如下代码

        protected void Application_BeginRequest(object sender, EventArgs e)
{
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)
{
} 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]);
}
else if (HttpContext.Current.Request.QueryString[auth_param_name] != null)
{
UpdateCookie(auth_cookie_name, HttpContext.Current.Request.QueryString[auth_param_name]);
} }
catch (Exception)
{
} }
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);
}
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,022
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,513
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,359
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,142
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,773
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,851