# SO-SignalR
## About this project
This repo is an example of integrating an [ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/?view=aspnetcore-2.2) backend with [SignalR](https://docs.microsoft.com/en-us/aspnet/core/signalr/introduction?view=aspnetcore-2.2) and a [VueJS](https://vuejs.org/) frontend.
It serves as an example of how VueJS can be integrated with SignalR by implementing a minimalistic version of Stack Overflow. SignalR is then used to propagate the changes to the question score and new questions, which serve as examples for receiving and sending events through the SignalR connection.
It's been covered by 2 articles in the DotNetCurry magazine:
- [Using ASP.NET Core SignalR with Vue.js (to create a mini Stack Overflow rip-off)](https://www.dotnetcurry.com/aspnet-core/1480/aspnet-core-vuejs-signalr-app)
- [Authentication in ASP.NET Core, SignalR and VueJS applications](https://www.dotnetcurry.com/aspnet-core/1511/authentication-aspnetcore-signalr-vuejs)
## Quick Start
1. Clone this repo.
1. Open a terminal and navigate to the client folder. Restore the dependencies with `npm install`, then run `npm run serve`. It will automatically reload when the client code changes.
1. Open a second terminal and navigate to the server folder. Restore the dependencies with `dotnet restore`, then run the server with `dotnet run`. Alternatively use `dotnet watch run` if you want to automatically reload when the server code changes.
1. The frontend will be listening on http://localhost:8080 while the backend will be listening at http://localhost:5100
## Backend
The backed is an ASP.NET Core 2.2 project providing a REST API. It was initialized using the [.NET Core CLI](https://docs.microsoft.com/en-us/dotnet/core/tools/?tabs=netcore2x) with `dotnet new webapi` and provides a simple API for viewing and adding the questions and answers of the site.
On top of that:
- it provides a SignalR hub where clients can connect so they receive an event when question scores change and new questions are added.
- allows clients authenticating using either of a cookie based schema or a jwt bearer schema
## Frontend
The frontend is a Vue 2.5 project. It was initialized using the [Vue-CLI 3](https://cli.vuejs.org/) with `vue create` and provides a minimalistic Stack Overflow site on top of the API provided by the backend, with Bootstrap used for styling.
The [SignalR JavaScript client](https://docs.microsoft.com/en-us/aspnet/core/signalr/javascript-client?view=aspnetcore-2.2) was installed and is used to intialize a connection with the backend SignalR hub during app startup. A simple Vue plugin is provided so any component can receive SignalR events from the server as well as submit events to the server.
[Vuex](https://vuex.vuejs.org/) is used to manage the state related with the user context. It provides methods to login/logout using either of the cookie or jwt bearer schemas, as well as centrally storing the current user profile.
没有合适的资源?快使用搜索试试~ 我知道了~
MiniStackOverflow副本用作集成Vue、ASP.NETCore和SignalR的示例项目_C#_Vue_下.zip
共42个文件
vue:10个
js:9个
cs:8个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 109 浏览量
2023-04-26
11:23:47
上传
评论
收藏 141KB ZIP 举报
温馨提示
MiniStackOverflow副本用作集成Vue、ASP.NETCore和SignalR的示例项目_C#_Vue_下.zip
资源推荐
资源详情
资源评论
收起资源包目录
MiniStackOverflow副本用作集成Vue、ASP.NETCore和SignalR的示例项目_C#_Vue_下.zip (42个子文件)
so-signalr-master
LICENSE.md 1KB
client
.editorconfig 121B
.browserslistrc 33B
babel.config.js 53B
.eslintrc.js 348B
src
App.vue 635B
store
context.js 3KB
index.js 180B
main.js 1KB
components
main-navbar.vue 1KB
live-chat-modal.vue 2KB
login-modal.vue 2KB
add-question-modal.vue 2KB
question-preview.vue 2KB
question-score.vue 2KB
add-answer-modal.vue 1KB
question-hub.js 3KB
views
question.vue 3KB
home.vue 2KB
router.js 370B
package.json 809B
public
favicon.ico 1KB
index.html 557B
package-lock.json 438KB
vue.config.js 74B
.gitignore 214B
README.md 370B
postcss.config.js 59B
.gitignore 417B
server
server.csproj 412B
appsettings.Development.json 146B
Hubs
QuestionHub.cs 1KB
Startup.cs 6KB
Properties
launchSettings.json 806B
Program.cs 679B
Controllers
AccountController.cs 4KB
QuestionController.cs 6KB
appsettings.json 105B
Models
Answer.cs 327B
Question.cs 409B
NameUserIdProvider.cs 259B
README.md 3KB
共 42 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功