惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Webroot Blog
Webroot Blog
U
Unit 42
A
About on SuperTechFans
宝玉的分享
宝玉的分享
月光博客
月光博客
C
CERT Recently Published Vulnerability Notes
P
Privacy International News Feed
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
P
Privacy & Cybersecurity Law Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
S
Securelist
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Spread Privacy
Spread Privacy
L
Lohrmann on Cybersecurity
Apple Machine Learning Research
Apple Machine Learning Research
K
Kaspersky official blog
Hugging Face - Blog
Hugging Face - Blog
B
Blog
I
Intezer
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
V
V2EX
L
LangChain Blog
AI
AI
G
GRAHAM CLULEY
T
Tor Project blog
人人都是产品经理
人人都是产品经理
D
Docker
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
I
InfoQ
Y
Y Combinator Blog
C
Comments on: Blog
GbyAI
GbyAI
www.infosecurity-magazine.com
www.infosecurity-magazine.com
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
N
News and Events Feed by Topic
MyScale Blog
MyScale Blog
H
Help Net Security
Vercel News
Vercel News
T
Tenable Blog
博客园 - 三生石上(FineUI控件)
爱范儿
爱范儿

博客园 - Jason Li 2011

Maven - import a web project into eclipse [分享] 兰迪·波许教授的最后一课[PDF/PPT/AVI] 转:Controlling Access to Members of a Class 转:退火算法 Simulate Anneal Arithmetic (SAA,模拟退火算法) Scrum in practise 转:MOSS 2007 and Code Access Security 转:CollaDec FriendlyQuery类库(beta)说明 转:MOSS站点的迁移(备份还原) 转:MOSS漫游(3):说说MOSS中的母版页 转:关于MOSS 2007的Content Types 转:Best Practices: Common Coding Issues When Using the SharePoint Object Model 转:Best Practices: Using Disposable Windows SharePoint Services Objects 转:Free the SPWeb Duff International Sites 项目总结 转:Code-blocks are not allowed in this file: Using Server-Side Code with SharePoint 转:ASP.NET Web Services or .NET Remoting: How to Choose 转:类与结构的差别 转:SharePoint Server 2007 页面模型 转:MOSS 2007基础:WSS 3.0 中的母版页(Master Pages)和内容页(Content Pages) 转:How to: Create a Minimal Master Page
转:将你的Asp.NET应用程序嵌入到SharePoint
Jason Li 2011 · 2010-12-29 · via 博客园 - Jason Li 2011

将你的Asp.NET应用程序嵌入到SharePoint

为什么要将Asp.net应用程序嵌入到SharePoint?这个我们不讨论!我们将要讨论的是如何将Asp.net应用程序嵌入到SharePoint,以及其中可能会遇到的问题。

正文开始:

    我们这里是建立了一个Web应用程序里面有一个Demo.aspx页,代码如下:

namespace WebInMOSS

{

public partial class _Demo: System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

Response.Write("Web Can In Moss");

}

}

}

将此程序编译,生成一个WebInMOSS.dll文件,将此dll拷贝到网站目录下bin文件夹,增加节点:

<SafeControl Assembly="WebInMOSS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Namespace="WebInMOSS" TypeName="*" Safe="True" />

然后将Demo.aspx页面放入MOSS中。放入方式你可以选择使用SPD,或者直接上传文档库。我们这里放入"Pages"中。

MOSS中浏览pages/Demo.aspx,

是否删除autoeventwireup就可以了呢?的确,在删除AutoEventWireup="true"

页面显示Web Can In Moss,证明执行成功。

增加web应用程序复杂度,在Demo.aspx放入一个button ,其事件如下:

    protected void Button3_Click(object sender, EventArgs e)

{

SPSite siteCollection = new SPSite("http://xuwei:8080");

SPWeb site = siteCollection.OpenWeb("/Docs/");

SPList list = site.Lists["通知"];

SPListItemCollection items = list.Items;

foreach (SPListItem item in items)

{

Response.Write("<br/>");

Response.Write(item["Title"].ToString());

}

}

在VS2005中调试得出结果(各位看客请先忽略write session和read session 2个button):

将重新编译后的程序dll,Demo.aspx按前面方式放入MOSS中。重新浏览

此时又出现Onclick事件不能使用,如何是好?我们必须启动MOSS的安全模式才能执行服务器端事件。操作如下:

我们找到Web.config 文件的<SharePoint>节点,在 <PageParserPaths> </PageParserPaths>

节点下增加一个虚拟路径 <PageParserPath VirtualPath="/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />

声明此站点下所有文件允许服务器端事件,当然你也可以制定虚拟目录是那个文件夹,但是这个值 必须以 ~/ / 开头,并且必须以文件名或 * 结尾。

保存Demo.aspx后浏览页面,能够正常显示,点击listobject button(各位看客请先忽略write sessionread session 2button)OK,正常执行显示了!

再次增加web应用程序复杂度,加入Session,(在MOSS开发中不管采取那种方式,只要是和自己的程序相集成,总会碰到Session的问题)。

代码如下:

    protected void Button1_Click(object sender, EventArgs e)

{

Session["Count"] = "1";

}

protected void Button2_Click(object sender, EventArgs e)

{

if (Session["Count"] != null)

{

Response.Write("<br><font color=red>"+Session["Count"].ToString()+"</font>");

}

}

编译保存后再次浏览页面,点击listobject button能够正常显示结果,可是当点击 Write Session时,出现

这个提示出现得够霸气!天晓得是什么意外错误!我试图修改<customErrors mode="Off" />MOSS显示出错误信息,但是失败。查找Log文件也没有

发现什么踪迹,还好 一开始就预计到Session可能会出现问题,检查Web.config发现

<pages enableSessionState="false" enableViewState="true" enableViewStateMac="true" validateRequest="false" pageParserFilterType="Microsoft.SharePoint.ApplicationRuntime.SPPageParserFilter, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" asyncTimeout="7">

呵呵,Session默认处于关闭状态,当然无法正常执行。将其设置为 true后保存。浏览demo.aspx页面,点击write session read Session,能够正常执行。

总算一些重要的问题能够解决了!如果再遇到其他问题,我们继续讨论!

将你的Asp.NET应用程序嵌入到SharePoint()

这次遇到的问题是如何将带User ControlWeb应用程序签入到MOSS

在将一个带User Control的应用程序嵌入到MOSS时,浏览页面出现

处理 MenuFrame.aspx 时出现错误。此页中不允许使用引用的文件" Department/DeptTree.ascx" Windows SharePoint Services 疑难解答。

又是一头雾水,难道MOSS不允许使用User Control么??难道只能使用Web part封装出来?要是封装

Web Part的话,我的Web应用程序改动就太大了。回想以前在做Custom Action的时侯修改过一个User Control,

那么在MOSS中就应该能够直接使用User Control的啊!在Web.Config里面搜索了半天,终于发现,有个节点

<SafeControl Src="~/_controltemplates/*" IncludeSubFolders="True" Safe="True" AllowRemoteDesigner="True" />

Controltemplates 不正是我当初修改MOSS usercontrols所在的位置么?看到此节点突然心中燃起了希望,对,就是此节点了,

于是赶紧Copy此节点,修改 Src为自己Web应用程序User Control所在的目录,保存Web.Config.重新浏览页面,Good!包含

User Control 页面可以使用了!测试一下,参数传递,数据库链接,属性赋值,都没有问题。呵呵,又 解决了一个问题

如果再遇到其他问题,我们继续讨论!

PS:我们还可以在MOSS站点中不用任何包装器来引用User Control,当然不能随意拖动是不爽!但是却不用写成WebPart。(*^__^*) 嘻嘻……

 

posted on 2010-12-29 22:39  Jason Li 2011  阅读(387)  评论()    收藏  举报