Office 365 Starter Project for ASP.NET MVC
来源:互联网 发布:java软件培训认证 编辑:程序博客网 时间:2024/05/16 16:15
Overview
This sample uses the Office 365 APIs client libraries to demonstrate basic operations against the Calendar, Contacts, Mail, and Files (OneDrive for Business) service endpoints in Office 365 from a single-tenant ASP.NET MVC 5 application.
Below are the operations that you can perform with this sample:
Calendar
- Read events
- Add events
- Refresh the calendar
- Update events
- Delete events
Contacts
- Add contacts
- Refresh the contacts list
- Update contacts
- Delete contacts
- Read email messages
- Create and send a new email
Files (OneDrive for Business)
- Read files and folders.
- Create text file.
- Delete files and folders.
- Read text file contents.
- Update text file contents.
Users and Groups
- Sign in/out
Prerequisites and Configuration
This sample requires the following:
- Visual Studio 2013 with Update 3.
- Microsoft Office 365 API Tools version 1.4.50428.2.
- An Office 365 developer site or another Office 365 tenant.
- Microsoft IIS enabled on your computer.
Register app and configure the sample to consume Office 365 APIs
You can do this via the Office 365 API Tools for Visual Studio (which automates the registration process). Be sure to download and install the Office 365 API tools from the Visual Studio Gallery before you proceed any further.
- Build the project. This will restore the NuGet packages for this solution.
- In the Solution Explorer window, choose O365-APIs-Start-ASPNET-MVC project -> Add -> Connected Service.
- A Services Manager window will appear. Choose Office 365 -> Office 365 APIs and select the Register your app link.
- If you haven't signed in before, a sign-in dialog box will appear. Enter the user name and password for your Office 365 tenant admin. We recommend that you use your Office 365 Developer Site. Often, this user name will follow the pattern {username}@{tenant}.onmicrosoft.com. If you do not have a developer site, you can get a free Developer Site as part of your MSDN Benefits or sign up for a free trial. Be aware that the user must be a Tenant Admin user—but for tenants created as part of an Office 365 Developer Site, this is likely to be the case already. Also developer accounts are usually limited to one user.
- After you're signed in, you will see a list of all the services. Initially, no permissions will be selected, as the app is not registered to consume any services yet.
- To register for the services used in this sample, choose the following permissions, and select the Permissions link to set the following permissions:
- (Calendar) – Read and write to your calendars (ReadWrite)
- (Contacts) – Read and write to your contacts (ReadWrite)
- (Mail) - Send mail as you (Send), Read and write to your mail (ReadWrite)
- (Files) - Read and write to your files (Write)
- (Users and Groups) – Sign you in and read your profile (Read)
- Choose the App Properties link in the Services Manager window. Make this app available to a Single Organization.
- After selecting OK in the Services Manager window, assemblies for connecting to Office 365 REST APIs will be added to your project and the following entries will be added to your appSettings in the web.config: ClientId, ClientSecret, AADInstance, and TenantId. You can use your tenant name for the value of the TenantId setting instead of using the tenant identifier.
- Build the solution. Nuget packages will be added to you project. Now you are ready to run the solution and sign in with your organizational account to Office 365.
Project Files of Interest
Controllers
AccountController.cs
CalendarController.cs
ContactController.cs
FileController.cs
HomeController.cs
MailContoller.cs
Helper Classes
AuthenticationHelper.cs
CalendarOperations.cs
ContactOperations.cs
FileOperations.cs
MailOperations.cs
Models
CalendarEvent.cs
ContactItem.cs
FileItem.cs
MailItem.cs
Utils Folder
SettingsHelper.cs
Views
Calendar/Create.cshtml
Calendar/Delete.cshtml
Calendar/Edit.cshtml
Calendar/Index.cshtml
Contact/Create.cshtml
Contact/Delete.cshtml
Contact/Edit.cshtml
Contact/Index.cshtml
File/Create.cshtml
File/Delete.cshtml
File/Edit.cshtml
File/Index.cshtml
Home/Index.cshtml
Mail/Create.cshtml
Mail/Delete.cshtml
Mail/Index.cshtml
Shared/_Layout.cshtml
Shared/_LoginPartial.cshtml
Other
RouteConfig.cs
web.config
Startup.cs
Startup.Auth.cs
packages.config
Troubleshooting
If you see any errors while installing packages, for example, Unable to find "Microsoft.Azure.ActiveDirectory.GraphClient" version="1.0.21", make sure the local path where you placed the solution is not too long/deep. Moving the solution closer to the root of your drive resolves this issue. We'll also work on shortening the folder names in a future update. There is a long file name restriction of about 260 characters in Visual Studio.
Your browser will not display a web page if you try to sign-in and the application doesn't have the Users and Groups, Enable sign-on and read users’ profiles option selected.
The Specified argument was out of the range of valid values. Parameter name: site will occur if IIS is not enabled.
An incorrect tenant identifier will return a 404 HTTP status code.
Check that you are running the same version of the Microsoft Office 365 API Tools as the version used for this sample.
Version 1.0.34 of Microsoft.Office365.OutlookServices.Portable contains a bug. This is the version installed by Microsoft Office 365 API Tools version 1.4.50428.2. Use 1.0.22 until a newer version is released.
- Office 365 Starter Project for ASP.NET MVC
- Asp.net Starter kit.
- Why MVC for ASP.NET?
- ActionFilter for MVC asp.net
- NVelocity for ASP.NET MVC
- How to use jquery or ajax to update razor partial view in c#/asp.net for a MVC project
- A great book for asp.net mvc
- ASP.NET WebForms and MVC together in one project
- ASP.NET Starter Kit 入门指南
- ASP.NET Portal Starter Kit 安装问题
- Using the ASP.NET Starter Kits
- ASP.NET Starter Kit 入门指南
- [收藏]ASP.NET Starter Kit 是啥咪碗糕?
- [收藏]ASP.NET Starter Kit 是啥咪碗糕?
- [收藏]ASP.NET Starter Kit 是啥咪碗糕?
- [收藏]ASP.NET Starter Kit 是啥咪碗糕?
- [收藏]ASP.NET Starter Kit 是啥咪碗糕?
- [收藏]ASP.NET Starter Kit 是啥咪碗糕?
- 利用反射机制创建新类的两种方式及比较
- Linux Epool 使用学习笔记
- NSLog打印优化
- undefined与null的区别
- RocketMQ与Kafka对比(18项差异)
- Office 365 Starter Project for ASP.NET MVC
- 最长单调递增子序列(O(n^2))
- 各种排序法的时间和空间复杂度表
- SDWebImage工作流程
- 数据挖掘十大经典算法
- 自己的选择,再难也要坚持—兄弟连IT教育
- swift 快速奔跑的兔几 本节的内容是:使用文件系统存储数据
- 百度搜索结果中link?url 格式的真实地址获取方式
- AutoCAD图形在紫金桥软件中的显示