Tag: model view controller

对“C:\ Windows \ system32 \ config \ systemprofile”路径的访问被拒绝

我正在使用Google Calendar Api和我的一个项目。 我不知道如何,但下面显示的错误是令人不安的。 AppFlowMetadata代码。 public class AppFlowMetadata : FlowMetadata { private static readonly IAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer { ClientSecrets = new ClientSecrets { ClientId = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com”, ClientSecret = “xxxxx_xxxxxxxxxxxxxxxxx” }, Scopes = new[] { CalendarService.Scope.Calendar }, DataStore = new FileDataStore(“Calendar.Api.Auth.Store”) }); public override string GetUserId(Controller controller) { var user = controller.Session[“UserID”]; if […]

应该使用MVC在每个View中使用ViewModel吗?

我知道您使用ViewModel来存储要在View中使用的其他模型和源的不同数据,因为模型不会始终保持您想要的。 我想弄清楚是否适合为每个View使用ViewModel。 我问的原因是出于一致性原因。 您可以拥有一个只需要Model本身的View和另一个必须拥有ViewModel的View。 在所有视图之间混合这些是否很好? 或者每个View都应该有一个ViewModel? 这很重要,因为我的模型与数据库直接相关,因为我正在使用Entity Framework 4.1 Code First。

c#MVC – 文件夹结构 – 放置类的位置?

在asp / net MVC中,该项目分为模型,视图和控制器。 好到目前为止。 假设我有一个类’人’,人控制器使用人模型填充数据。 把我的person.cs课最好放在哪里? 在控制器或模型文件夹中? 你是做什么? 谢谢 坦率

如何在Kendo Grid MVC中将列宽设置为自动调整

我用到了具有多列的Kendo网格页面。 我想设置一个列宽自动调整并自动更改宽度。 Plz帮助我,谢谢 @(Html.Kendo().Grid() .Name(“grdMarahel_Gardeshkar”) .ToolBar(toolbar => toolbar.Custom().Name(“btnAddMarhaleh”).Text(“اضافه”).HtmlAttributes(new { id = “btnAddMarhaleh”, href = “#” })) .Columns(columns => { columns.Bound(c => c.Code).Width(50).Title(“کد”); columns.Bound(c => c.Desc).Width(150).Title(“شرح”);//Autofit columns.Command(c => c.Destroy().Text(“حذف”)).Width(70).Title(“عملیات”); }) .HtmlAttributes(new { style = “height: 380px;” }) .Scrollable() .Sortable() .Resizable(rl => rl.Columns(true)) .Selectable(sl => sl.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row)) .DataSource(dataSource => dataSource .Ajax() .Model(m => m.Id(p => p.id)) .Read(read => […]

将模型从一个动作传递到同一控制器中的另一个动作

我试图将我的模型List statementList从一个动作传递到另一个动作,但我在第二个控制器中接收空值。 请在这里建议有什么问题。 甚至试过: return RedirectToAction(“WriteInTemplate”, new { statementList = statementList }); 请帮忙。 public ActionResult SendPdfStatement(string InvoiceNumber) { try { InvoiceNumber = InvoiceNumber.Trim(); ObjectParameter[] parameters = new ObjectParameter[1]; parameters[0] = new ObjectParameter(“InvoiceNumber”, InvoiceNumber); List statementList = new List(); statementList = _db.ExecuteFunction(“uspInvoiceStatement”, parameters).ToList(); //WriteInTemplate(statementList); return RedirectToAction(“WriteInTemplate”, statementList ); } catch (Exception e) { InvoiceSearchTool.Models.udtExceptionTable exception = […]

网站要求MVC控制器上的“需要身份validation”,而不是其他人

我有一个asp.net C#MVC网站。 它使用SimpleAuthentication和表单身份validation。 一切正常,要求人们登录进入页面。 但是,我有一个名为“ReportsController”的控制器。 每当您转到此控制器中的操作的URL时,它总是会在浏览器窗口中弹出“需要validation”。 它只是为这个控制器而不是任何其他控制器。 该url为“www.domain.com/reports”。 当我从IIS和我的开发服务器运行时,此URL工作正常,但不在我的实时服务器上运行。 这是运行IIS7。 我已经检查了我的web.config,它肯定是设置为Forms身份validation而不是Windows。 任何人都有任何想法为什么任何以“/ Reports”开头的url都不起作用。 我猜它是服务器特有的东西,比如IIS设置或web.config更改,但我无法弄清楚它会是什么。 namespace ProjectName.Controllers { public class ReportsController : Controller { public ActionResult Index() { throw new SystemException(“here”); return View(); } } } Web.config文件:

在SQL Server中加入逗号分隔值

我正在用LINQ写一个问题加入li。 如何获得包含3个表组合的结果表? 我必须将表格合并在一行中。 有任何想法吗? Peole ————— Id | 1 Id |2 Name | David Name |Ameyy Surname| David1 Surname |Ameyy2 Appointment ————— Id |19 PeopleId |1 Subject |description Participant ————— Id |1 Id |2 AppointmentId |19 AppointmentId |19 PeopleId |1 PeopleId |2 Result ———————————- Id | 1 Subject | Subject Participant| David David1, Ameyy Ameyy2 […]

如何在MVC中解析’访问令牌已过期,但我们无法刷新它’

我目前正致力于谷歌Api ,旨在获得一个登录人员的圈子。我已经拥有访问令牌,但问题是每当我尝试运行我的代码时它返回此exception 访问令牌已过期但我们无法刷新它 我该如何解决这个问题? var claimsforUser = await UserManager.GetClaimsAsync(User.Identity.GetUserId()); var access_token = claimsforUser.FirstOrDefault(x => x.Type == “urn:google:accesstoken”).Value; string[] scopes = new string[] {PlusService.Scope.PlusLogin, PlusService.Scope.UserinfoEmail, PlusService.Scope.UserinfoProfile}; var flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer { ClientSecrets = new ClientSecrets { ClientId = “xx-xx.apps.googleusercontent.com”, ClientSecret = “v-xx”, }, Scopes = scopes, DataStore = new FileDataStore(“Store”), }); var token = […]

在WPF项目中更改Main

总是烦恼我C#想要为你做这个创业公司。 所以现在我正在尝试制作自己的主要方法。 这不起作用: 我提供了这个主要方法: [System.STAThreadAttribute()] [System.Diagnostics.DebuggerNonUserCodeAttribute()] public static void Main() { Model model= new Model(); Controller controller = new Controller(model); MainWindow window = new MainWindow(controller, model); } 这个方法运行,但我看不到任何视觉效果。 我想我错过了以下正常主要代码: Application.App app = new Application.App(); app.InitializeComponent(); app.Run(); 我尝试使用相同的代码覆盖OnStartUp,但是会引发exception。 如果您有其他解决方案,我愿意听。 我只是不明白为什么我的MainWindow必须先创建。

你可以从ApiController类访问GetOwinContext()。GetUserManager吗?

我在api中做一个项目,我需要从ApiController类访问: var result = await SignInManager.PasswordSignInAsync (model.UserName,model.Password… 但我也没有访问权限 HttpContext.Current.GetOwinContext().GetUserManager() nor Request.GetOwinContext().GetUserManager(); 基本上我需要检查用户名和密码是否正确。 编辑:我参考了microsoft.owin.host.SystemWeb和ConfigureAuth app.CreatePerOwinContext();