我有一个Web API,看起来像以下......
public class LeaguesController : ApiController
{
//api/Leagues/active/1
//api/Leagues/complete/1
//api/Leagues/both/1
[GET("api/Leagues/{type}/{id}")]
public List<Competition> Get([FromUri]int id,
[FromUri]CompetitionManager.MiniLeagueType type)
{
return CompetitionManager.GetUsersMiniLeagues(id, true, type);
}
//api/Leagues/GetMiniLeagueTable/3
[GET("api/Leagues/GetMiniLeagueTable/{id}")]
public List<SportTableRow> GetMiniLeagueTable([FromUri]int id)
{
return SportManager.GetMiniLeagueTable("", id).TableRows;
}
}
Run Code Online (Sandbox Code Playgroud)
当我调用第一种方法时Get,这很好用.当我使用fiddler或Chrome REST Client调用第二种方法时GetMiniLeagueTable,我收到以下错误:
{消息:"请求无效." MessageDetail:"参数字典包含参数'type'的非可为空类型'CompetitionManager + MiniLeagueType'的空条目,方法'System.Collections.Generic.List`1 [竞争] Get(Int32,MiniLeagueType)''LeaguesController '.可选参数必须是引用类型,可以为空的类型,或者声明为可选参数." }
我AttributeRouting用来装饰方法,但这似乎不起作用.在我介绍之前它工作正常MiniLeagueType.
有人遇到过这个问题,还是你能指出我哪里出错了?
我正在执行两个http请求,每个请求都返回a observable<IProduct>;,我想将两者都组合到一个本地对象中,并使用异步管道从每个请求中获取值。
productA$: observable<IProduct>;
productB$: observable<IProduct>;
combinedProds$: ?
this.productA$ = httpCall();
this.productB$ = httpCall();
this.combinedProds$ = combineLatest([
this.productA$,
this.productB$
])
.pipe(
map(([productA, productB]) =>
({ productA, productB}))
);
Run Code Online (Sandbox Code Playgroud)
我遇到的这个问题,我不知道combinedProds$应该是哪种类型。
我为此搜索了SO,但没有遇到任何明显的问题.我有一个工作仪表板,它们的状态在一天中不断变化,我正在尝试将一些概念证明应用程序放在一起,并通过在数据库中运行更新命令来手动触发更新.这就是我设置的,但是当我执行更新时,我看不到UI的任何变化,你能看到我哪里出错吗?
毂:
public class DashboardHub : Hub
{
private readonly Repository _repository;
public DashboardHub()
{
_repository= new Repository();
}
public void GetJobs()
{
var jobs = _repository.GetJobs();
Clients.All.allJobsRetrieved(jobs);
}
}
Run Code Online (Sandbox Code Playgroud)
淘汰视图模型
$(function () {
$(function () {
function jobViewModel(id, name, isPaused, currentStatus, cob, owner) {
this.hub = $.connection.dashboardHub;
//job variables, initialised from params
this.Id = id;
this.Name = ko.observable(name);
this.IsPaused = ko.observable(isPaused);
this.CurrentStatus = ko.observable(currentStatus);
this.Cob = ko.observable(cob);
}
function dashboardViewModel() {
this.hub = $.connection.dashboardHub;
//jobs collection
this.jobs = ko.observableArray([]); …Run Code Online (Sandbox Code Playgroud) 我在IE9中的项目ASp.NEt c#中使用Session有问题.有时会出现错误:"对象引用未设置为对象的实例"
其他问题是在IE9中,有时候不会保存我的Session以将Idiom更改为其他页面.在Chrome中一切都很好!


下面是我的Page_Load和CarregaGrid().此问题有时发生,没有时间发生,并且在任何页面中都没有出现在所有页面中或只出现在一个特定页面中.
public void CarregaGrid()
{
var listByGroupM = new ManageUsers().ConsultUsersGroupM();
if (listByGroupM != null)
{
this.GridView1.DataSource = listByGroupM;
if (listByGroupM.Count != 0)
{
this.GridView1.DataBind();
GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
}
}
if (divModify.Visible == true)
{
foreach (GridViewRow row in GridView1.Rows)
{
string idioma = CultureInfo.CurrentCulture.TwoLetterISOLanguageName.ToString();
if (Session["idioma"].ToString() != null)
{
idioma = Session["idioma"].ToString();
}
Idioma.MudaCultura(idioma);
Button btnDelete = (Button)row.FindControl("btnDelete");
btnDelete.Text = Idioma.RetornaMensagem("btnDelete");
string UserName = row.Cells[1].Text;
PrincipalContext insPrincipalContext = new PrincipalContext(ContextType.Domain, "x.com", "x", "xxx");
UserPrincipal insUserPrincipal = UserPrincipal.FindByIdentity(insPrincipalContext, …Run Code Online (Sandbox Code Playgroud) 我对MVC 4很陌生,到目前为止我在C#中主要使用Web表单.我理解MVC的模式,路由,调用动作等等.
但是负责从数据库中获取数据的操作呢,例如通过激活存储过程?我看过一些教程,他们在操作中直接连接数据库的逻辑.
但是,我正在考虑采用更集中的方式来实现它.例如,我可以将所有触发存储过程的函数放在一个名为DatabaseCoordinator.cs的单独类中,例如,名为Helpers的文件夹中.然后我可以从控制器中的动作调用它们.
通过这种方式,我将知道我可以在一个类中找到我的所有数据库方法,这是一个非常干净的解决方案,我认为(或至少在Web表单中).但是我想遵循MVC的模式,并且只使用模型,视图和控制器作为模式本身的名称.
那么最佳做法是什么?我应该为此单独创建一个类,还是直接在控制器中或者在其他地方实现逻辑?
我在PostgreSQL插入请求中有一些想法是不正确的.当我执行:
INSERT INTO data
( Email ,
Email_MD5 ,
Date_In ,
Tel_mobile ,
Tel_fixe ,
Gender ,
Title ,
FirstName ,
LastName ,
DateOfBirth ,
YearOfBirth ,
AgeGroupe ,
Adresse_1 ,
Adresse_2 ,
CP ,
Ville ,
Domain ,
Groupe_Domaine ,
Last_Date_R ,
Last_Date_O ,
Last_Date_C ,
Pression ,
Activity ,
R
)
VALUES ( "000090@voila.fr" ,
"b6ffc0c54f2c35866c4ccc4a7218472c" ,
NULL ,
"" ,
"5789332" ,
"MLLE" ,
"" ,
"Lydia" ,
"Le Port" ,
NULL ,
NULL ,
"26 - …Run Code Online (Sandbox Code Playgroud) 我正在关注John Papa的Angular Style指南来创建一个小应用程序,我似乎无法解决controller使用a service...中的方法的问题.
模
(function () {
'use strict';
var accountsApp = angular.module('accountsApp', ['ui.bootstrap', 'ngAnimate']);
})();
Run Code Online (Sandbox Code Playgroud)
调节器
(function() {
'use strict';
angular
.module('accountsApp')
.controller('accountsCtrl', accountsCtrl);
accountsCtrl.$inject = ['$log'];
function accountsCtrl($log, accountsDataSvc) {
/* jshint validthis:true */
var vm = this;
vm.title = 'Accounts';
vm.accounts = [];
vm.accountForm = null;
vm.account = { id: 0, name: '', description: '' }
activate();
function activate() {
return getAccounts(1).then(function() {
$log.info('Accounts loaded');
});
}
function getAccounts(id) {
return accountsDataSvc.getAccounts(id).then(function(data) { …Run Code Online (Sandbox Code Playgroud) 我将我的打字稿项目移到了 win 7 计算机上。当 tsconfig 在我的 win 10 计算机上运行良好时,我收到此错误。我按照此处的建议删除了最后两个尾随逗号,但错误仍然存在。
我的 tsconfig:
{
"compileOnSave": true,
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"strict": true, /* Enable …Run Code Online (Sandbox Code Playgroud) 我正在尝试在会话中保存数组并尝试将其恢复。以下是代码。但是当我调用 WebMethod 时出现以下错误。我正在使用c#。VS2010
错误:
System.NullReferenceException:未将对象引用设置为对象的实例。在 C:\Users\uydarp\Documents\Visual Studio 2010\Projects\xmlRW1\xmlRW1\Service1.asmx.cs 中的 xmlRW1.Service1.logic() 处:第 86 行
[WebMethod]
public int logic()
{
int[] myArray = { 1,2,3,4};
Session["MyArray"] = myArray;
int[] myArray2 = (int[])Session["MyArray"];
int firstElement = myArray2[0];
return firstElement;
}
Run Code Online (Sandbox Code Playgroud) 我有以下代码,应该在我的客户端脚本中调用一个名为ShowPopup的函数,但是有理由,当我调用此函数时没有任何反应.
string pg = "Test";
ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup(pg);", true);
Run Code Online (Sandbox Code Playgroud)
如果我执行以下操作:
ClientScript.RegisterStartupScript(
this.GetType(), "Popup", "ShowPopup('Test');", true);
Run Code Online (Sandbox Code Playgroud)
它工作正常.它确实出现在弹出窗口中.知道我可能做错了什么.
c# ×5
asp.net ×3
javascript ×2
typescript ×2
.net ×1
.net-4.5 ×1
angular ×1
angularjs ×1
asp.net-mvc ×1
iife ×1
knockout.js ×1
postgresql ×1
rxjs ×1
signalr ×1
sql ×1
tsconfig ×1
web-services ×1
webforms ×1