Visual Studio 2013 添加一般应用程序(.ashx)文件到SharePoint项目
默認(rèn),在用vs2013開發(fā)SharePoint項(xiàng)目時(shí),vs沒有提供一般應(yīng)用程序(.ashx)的項(xiàng)目模板,本文解決此問(wèn)題。
效果:
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
?
<%@ WebHandler Class="$SharePoint.Type.be94b0d0-ca37-4783-b8e9-06ba0477a22f.FullName$" %>
using System;
using System.Web;
using System.Runtime.InteropServices;
namespace SharePointProject2.Layouts.SharePointProject2
{
[Guid("be94b0d0-ca37-4783-b8e9-06ba0477a22f")]
public partial class ApplicationPage1 : IHttpHandler
{
#region IHttpHandler Members
public bool IsReusable
{
get { throw new NotImplementedException(); }
}
public void ProcessRequest(HttpContext context)
{
//throw new NotImplementedException();
context.Response.Write("123");
}
#endregion
}
}
?
在PropertyGroup節(jié)點(diǎn)下面,添加如下:
<TokenReplacementFileExtensions>ashx</TokenReplacementFileExtensions>
十一.右擊項(xiàng)目"SharePointProject2",選擇"重新加載項(xiàng)目",注意要關(guān)閉我們打開的SharePointProject2.csproj文件。
十二.右擊項(xiàng)目"SharePointProject2",選擇"部署"。打開瀏覽器就可以瀏覽了。
關(guān)于GUID的生成,請(qǐng)?jiān)趘s里,選擇"工具"----"創(chuàng)建GUID"
關(guān)于上面的"六","七"步,如果不想使用GUID的形式,也可以使用如下方式(去掉紅星劃掉的部分):
即:把a(bǔ)shx中的Class改為"命名空間.類名"的格式。
如遇報(bào)錯(cuò),請(qǐng)
右擊"ApplicationPage1.ashx"選擇"屬性",然后把"生成操作"改為"內(nèi)容"。
右擊"ApplicationPage1.ashx.cs" 選擇"屬性",然后把"生成操作"改為"編譯"。
關(guān)于如何在Visual Studio 2010的SharePoint項(xiàng)目中添加一般應(yīng)用程序(.ashx),建議安裝vs2010插件cks(http://cksdev.codeplex.com/).
當(dāng)然也可以按上面的方法進(jìn)行,執(zhí)行把"六"中的前兩行代碼改為:
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
?
參考:
https://cann0nf0dder.wordpress.com/2013/05/22/creating-generic-httphandler-in-sharepoint/
http://www.lifeonplanetgroove.com/adding-and-deploying-generic-handlers-ashx-to-a-sharepoint-2010-visual-studio-project/
https://peakfinders.blogspot.jp/2015/03/adding-and-deploying-generic-handlers.html
http://blog.csdn.net/abrahamcheng/article/details/20490757#
轉(zhuǎn)載于:https://www.cnblogs.com/sygwin/p/6179680.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的Visual Studio 2013 添加一般应用程序(.ashx)文件到SharePoint项目的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Android 取消返回键返回事件,返回
- 下一篇: c语言编程题-输出素数