我有一个 Web API,它可以完美地处理所有类型的 HTTP 请求(在同一个控制器上),一旦我将它移到生产环境(共享服务器,我什至无法访问它),DELETE
请求就停止工作(其他工作正常),我收到 404 错误:
请求的 URL https://www.example.com:443/ Rejected-By-UrlScan~ /API/Users/DeleteUser/1
物理路径 d:\xx\yy\example.com\Rejected-By-UrlScan
匿名登录方法
登录用户匿名
这是 web.config(的一部分):
<system.web>
<customErrors mode="Off"/>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
删除操作:
[Authorize]
[RoutePrefix("Users")]
public class UsersController : ApiController
{
[HttpDelete]
[Route("DeleteUser/{id:int}")]
public void Delete(int id)
{
_UsersRepository.Delete(id); …
Run Code Online (Sandbox Code Playgroud) 当我尝试启动该服务时,我收到以下错误:
服务无法启动.System.ArgumentException:源'Bar source'未在日志'Bar2'中注册.(它在日志'Bar source'中注册.)"Source和Log属性必须匹配,或者您可以将Log设置为空字符串,它将自动匹配Source属性.在System.Diagnostics.EventLogInternal.在Bar.Service1的System.Diagnostics.EventLog.WriteEntry(String message)上的System.Diagnostics.EventLogInternal.WriteEntry(String message,EventLogEntryType type,Int32 eventID,Int16 category,Byte [] rawData)中的VerifyAndCreateSource(String sourceName,String currentMachineName) C:\ Program Files(x86)\ Bar中的.writeToLog(String msg) - 用于AP:\ Service1.vb:C:\ Program Files(x86)中Bar.Service1.OnStart(String [] args)的第292行栏 - 用于APPS\Service1.vb:第37行,System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(对象状态)
有谁知道什么会导致这个问题?我Bar2
在代码中没有提到,程序文件中的文件夹被称为"Bar2",但我将其更改为"Bar".
请指教!
这是WriteToLog
功能:
Private Sub writeToLog(ByVal msg As String)
Dim evtLog As New EventLog
If Not Diagnostics.EventLog.SourceExists("Bar") Then
Diagnostics.EventLog.CreateEventSource("Bar", "Log of Bar")
End If
evtLog.Source = "Bar"
evtLog.Log = "Log of Bar"
evtLog.WriteEntry(msg)
End Sub
Run Code Online (Sandbox Code Playgroud) 我有一个Employee
类,如下所示:
public class Employee : INotifyPropertyChanged
{
public Employee()
{
_subEmployee = new ObservableCollection<Employee>();
}
public string Name { get; set; }
public ObservableCollection<Employee> SubEmployee
{
get { return _subEmployee; }
set
{
_subEmployee = value;
NotifiyPropertyChanged("SubEmployee");
}
}
ObservableCollection<Employee> _subEmployee;
public event PropertyChangedEventHandler PropertyChanged;
void NotifiyPropertyChanged(string property)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}
Run Code Online (Sandbox Code Playgroud)
我正在Main窗口构造函数中创建一个employee类的集合,并将其添加到一个可观察的员工集合中,如下所示:
public partial class MainWindow : Window
{
public ObservableCollection<Employee> Emp { get; private set; }
public MainWindow()
{
InitializeComponent(); …
Run Code Online (Sandbox Code Playgroud) 我正在使用新的Dropbox SDK v2 for .NET.
我正在尝试将文档上传到Dropbox帐户.
public async Task UploadDoc()
{
using (var dbx = new DropboxClient("XXXXXXXXXX"))
{
var full = await dbx.Users.GetCurrentAccountAsync();
await Upload(dbx, @"/MyApp/test", "test.txt","Testing!");
}
}
async Task Upload(DropboxClient dbx, string folder, string file, string content)
{
using (var mem = new MemoryStream(Encoding.UTF8.GetBytes(content)))
{
var updated = await dbx.Files.UploadAsync(
folder + "/" + file,
WriteMode.Overwrite.Instance,
body: mem);
Console.WriteLine("Saved {0}/{1} rev {2}", folder, file, updated.Rev);
}
}
Run Code Online (Sandbox Code Playgroud)
此代码段实际上在Dropbox帐户上创建了一个test.txt文档,其中包含"Testing!" 内容,但我想上传一个带有给定路径的文档(例如:"C:\ MyDocuments\test.txt"),这可能吗?
任何帮助将非常感谢.
我有一个使用 Windows 身份验证设置的 Intranet 应用程序。我需要在标题中显示用户名和用户姓名首字母,例如:
欢迎 jSmith JS
到目前为止我做了什么:
<div class="header__profile-name">Welcome <b>@User.Identity.Name.Split('\\')[1]</b></div>
<div class="header__profile-img">@User.Identity.Name.Split('\\')[1].Substring(0, 2)</div>
Run Code Online (Sandbox Code Playgroud)
问题是用户名并不总是名字的第一个字母+姓氏,有时用户名可以是名字+姓氏的第一个字母,例如:
John Smith - 用户名可以是jsmith但有时也可以是:johns
在那种情况下,我的代码是错误的,因为它会导致:
jo而不是js
我怎样才能获得完整的用户名:名字和姓氏User.identity
?
然后我将基于完整的用户名(名字和姓氏)来设置我的代码,以便设置首字母,而不是基于不总是一致的用户名。
我有这个LoanWithClient
继承自以下的模型Loan
:
public class LoanWithClient : Loan
{
public Client Client { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
如何在不显式写入其属性的情况下访问整个继承的Loan
对象?
LoanWithClient不包含贷款的定义
return new LoanWithClient
{
**Loan** = loan, //The Loan is erroring: LoanWithClient does not contain a definition for Loan
Client = client
};
Run Code Online (Sandbox Code Playgroud)
类贷款:
public class Loan
{
public int ID { get; set; }
public string Address { get; set; }
public string City { get; set; }
//etc..
}
Run Code Online (Sandbox Code Playgroud) 在我的MVC项目中,我有一个与Knockout绑定的HTML表.
我正在尝试将表导出到Excel.
我尝试在客户端使用JavaScript:
self.exportToExcel = function () {
javascript: window.open('data:application/vnd.ms-excel,' + $("#tableToprint").innerHTML());
}
Run Code Online (Sandbox Code Playgroud)
要么:
var tableToExcel = (function () {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table cellspacing="0" rules="rows" border="1" style="color:Black;background-color:White;border-color:#CCCCCC;border-width:1px;border-style:None;width:100%;border-collapse:collapse;font-size:9pt;text-align:center;">{table}</table></body></html>'
, base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) }
return function (table, name) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = { worksheet: name …
Run Code Online (Sandbox Code Playgroud) 我已经阅读了很多,promises
但我仍然不确定如何实现它。
我编写了以下 AJAX 调用async=false
以使其正常工作,但我想用 Promise 替换它,因为我发现它async=false
已被弃用。
self.getBalance = function (order) {
var balance;
$.ajax({
url: "/API/balance/" + order,
type: "GET",
async: false,
success: function (data) {
balance = data;
},
done: function (date) {
}
});
return balance;
}
Run Code Online (Sandbox Code Playgroud)
你能帮我吗?我只需要一个例子来理解它。
我有这个map
功能:
return docTypes.map(docType => ({
label: docType.docType,
value: docType.id,
}));
Run Code Online (Sandbox Code Playgroud)
如何添加条件以仅返回 if docType.generic = true
?
有人可以解释一下函数参数中的含义是什么,我不明白on[]
的目的是什么。[]
[fileEntry]
const onDrop = ([fileEntry]: any[]) => {
fileEntry && fileEntry.file(file => processFile(file))
}
Run Code Online (Sandbox Code Playgroud)
它会将 转换fileEntry
为数组吗?如果是的话为什么那行不通?
const onDrop = (fileEntry) => {
fileEntry = [fileEntry]
fileEntry && fileEntry.file(file => processFile(file))
}
Run Code Online (Sandbox Code Playgroud) c# ×4
javascript ×3
asp.net-mvc ×2
.net ×1
ajax ×1
asynchronous ×1
dropbox ×1
dropbox-api ×1
jquery ×1
knockout.js ×1
promise ×1
treeview ×1
typescript ×1
wpf ×1