Why apply Asp.netProgramEmbedded in SharePoint? We will not discuss this! We will discuss how to embed the Asp.net application into SharePoint and the possible problems.
Body start:
We have created a web application with a demo. ASPX page,CodeAs follows:
NamespaceWebinmoss
{
Public Partial Class _ Demo: System. Web. UI.Page
{
Protected VoidPage_load (ObjectSender,EventargsE)
{
Response. Write ("Web can in moss");
}
}
}
Compile this program, generate a webinmoss. dll file, copy the DLL to the bin folder under the website directory, and add nodes:
<Safecontrol Assembly = "webinmoss, version = 1.0.0.0, culture = neutral, publickeytoken = NULL" namespace = "webinmoss" typename = "*" Safe = "true"/>
Then, add the demo. ASPX page to the moss. You can choose to use Spd or directly upload the document library. Here we put it in "pages.
Browse pages/demo. aspx in Moss,
Can I delete autoeventwireup? Indeed, after deleting autoeventwireup = "true ",
The Web can in Moss is displayed, proving that the execution is successful.
To increase the complexity of Web applications, put a button in demo. aspx. The event is as follows:
Protected VoidButton3_click (ObjectSender,EventargsE)
{
SpsiteSitecollection =New Spsite("Http: // xuwei: 8080");
SpwebSite = sitecollection. openweb ("/Docs /");
SplistList = site. Lists ["Notification"];
SplistitemcollectionItems = List. items;
Foreach(SplistitemItemInItems)
{
Response. Write ("<Br/>");
Response. Write (item ["Title"]. Tostring ());
}
}
Debugging results in vs2005 (ignore the write session and read session Buttons First ):
Recompile the program DLL, demo. aspx, and put it in the moss. Browse again
Now the onclick event is unavailable. How can this problem be solved? We must start the moss security mode to execute server-side events. The procedure is as follows:
Find the <SharePoint> node in the web. config file and go to <pageparserpaths> </pageparserpaths>
Add a virtual path under the node <pageparserpath virtualpath = "/*" compilationmode = "always" allowserversidescript = "true" includesubfolders = "true"/>
Declare that all files on the site Allow server events. You can also specify the folder where the virtual directory is, but this valueMust start ~ // Or/, and must end with a file name or.
Save demo. aspx and browse the page. The page will be displayed normally. Click the listobject button (ignore the write session and read session Buttons First). OK. It will be displayed normally!
Increase the complexity of web applications and add sessions again (no matter which method is used in Moss development, as long as it is integrated with its own program, it will always encounter session problems ).
The Code is as follows:
Protected VoidButton#click (ObjectSender,EventargsE)
{
Session ["Count"] ="1";
}
Protected VoidButton2_click (ObjectSender,EventargsE)
{
If(Session ["Count"]! =Null)
{
Response. Write ("<Br> <font color = Red>"+ Session ["Count"]. Tostring () +"</Font>");
}
}
After compilation and storage, browse the page again and click the listobject button to display the result normally. However, when you click write session
This prompt is domineering! What is an unexpected error! I tried to modify <customerrors mode = "off"/> to display an error message to Moss, but failed. No log files found
What trace was found, but it was expected that the session might be faulty at the beginning. Check web. config and find
<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 ">
The session is disabled by default and cannot be executed normally. Set it to true and save it. Go to the demo. ASPX page and click write session and read session to run properly.
Finally, some important problems can be solved! If you encounter other problems, we will continue to discuss them!