日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Visual Studio 2013 添加一般应用程序(.ashx)文件到SharePoint项目

發布時間:2023/12/10 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Visual Studio 2013 添加一般应用程序(.ashx)文件到SharePoint项目 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

默認,在用vs2013開發SharePoint項目時,vs沒有提供一般應用程序(.ashx)的項目模板,本文解決此問題。

  • 以管理員身份啟動vs2013,創建一個"SharePoint 2013 - 空項目",名稱我保持默認:SharePointProject2。
  • 選擇"部署為場解決方案",結果如下:
  • 右擊"SharePointProject2",選擇"添加"----SharePoint 的"Layouts"映射文件夾,結果如下:

  • 右擊Layouts下的SharePointProject2文件夾,選擇添加---新建項,選擇"應用程序頁(僅場解決方案)",修改名稱,注意文件擴展名改為:ashx

    效果:

  • 右擊"ApplicationPage1.ashx.designer.cs"選擇刪除,此文件不是我們必需的。
  • 修改ApplicationPage1.ashx為如下內容(留意紅框中的內容):
  • <%@ 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$" %>

  • 修改ApplicationPage1.ashx.cs內容如下(注意紅框中的GUID和上面的GUID要保持一致):
  • 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

    }

    }

    ?

  • 右擊項目名"SharePointProject2",選擇"卸載項目",如有提示,請選擇"是"來保存項目
  • 再次右擊項目名"SharePointProject2",選擇"編輯SharePointProject2.csproj"
  • 修改如下,然后保存:

    在PropertyGroup節點下面,添加如下:

    <TokenReplacementFileExtensions>ashx</TokenReplacementFileExtensions>

  • 十一.右擊項目"SharePointProject2",選擇"重新加載項目",注意要關閉我們打開的SharePointProject2.csproj文件。

    十二.右擊項目"SharePointProject2",選擇"部署"。打開瀏覽器就可以瀏覽了。

    關于GUID的生成,請在vs里,選擇"工具"----"創建GUID"

    關于上面的"六","七"步,如果不想使用GUID的形式,也可以使用如下方式(去掉紅星劃掉的部分):

    即:把ashx中的Class改為"命名空間.類名"的格式。

    如遇報錯,請

    右擊"ApplicationPage1.ashx"選擇"屬性",然后把"生成操作"改為"內容"。

    右擊"ApplicationPage1.ashx.cs" 選擇"屬性",然后把"生成操作"改為"編譯"。

    關于如何在Visual Studio 2010的SharePoint項目中添加一般應用程序(.ashx),建議安裝vs2010插件cks(http://cksdev.codeplex.com/).

    當然也可以按上面的方法進行,執行把"六"中的前兩行代碼改為:

    <%@ 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#

    轉載于:https://www.cnblogs.com/sygwin/p/6179680.html

    創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

    總結

    以上是生活随笔為你收集整理的Visual Studio 2013 添加一般应用程序(.ashx)文件到SharePoint项目的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。