当我尝试运行我的应用程序时,我收到错误
InvalidOperationException: Cannot resolve 'API.Domain.Data.Repositories.IEmailRepository' from root provider because it requires scoped service 'API.Domain.Data.EmailRouterContext'.
Run Code Online (Sandbox Code Playgroud)
奇怪的是,这个EmailRepository和界面设置完全相同,因为我可以告诉所有其他存储库,但没有为它们抛出错误.只有在我尝试使用app.UseEmailingExceptionHandling()时才会出现错误; 线.这是我的一些Startup.cs文件.
public class Startup
{
public IConfiguration Configuration { get; protected set; }
private APIEnvironment _environment { get; set; }
public Startup(IConfiguration configuration, IHostingEnvironment env)
{
Configuration = configuration;
_environment = APIEnvironment.Development;
if (env.IsProduction()) _environment = APIEnvironment.Production;
if (env.IsStaging()) _environment = APIEnvironment.Staging;
}
public void ConfigureServices(IServiceCollection services)
{
var dataConnect = new DataConnect(_environment);
services.AddDbContext<GeneralInfoContext>(opt => opt.UseSqlServer(dataConnect.GetConnectString(Database.GeneralInfo)));
services.AddDbContext<EmailRouterContext>(opt => opt.UseSqlServer(dataConnect.GetConnectString(Database.EmailRouter)));
services.AddWebEncoders();
services.AddMvc();
services.AddScoped<IGenInfoNoteRepository, GenInfoNoteRepository>();
services.AddScoped<IEventLogRepository, EventLogRepository>(); …Run Code Online (Sandbox Code Playgroud) 好的,通常我认为自己是jquery的中间用户,但这似乎是一个非常noob的问题,我不太确定如何编码.
我有一个div,我想运行一个函数.我知道如何做到这一点的唯一方法是......
$("#divname").each(function(){
dostuff();
});
Run Code Online (Sandbox Code Playgroud)
当我知道只有一个元素时,这似乎更有用.我试过这个......
$("#divname", function(){
console.log($(this));
});
Run Code Online (Sandbox Code Playgroud)
......但它写出了整个dom.我只想在这一个元素上运行该函数.我怎么做?
我创建了一个新的rails应用程序,并按照rspec-rails的安装说明进行操作 - https://github.com/rspec/rspec-rails 然后我创建(从interwebs中复制)我的app/lib目录中的以下模块.
require 'openssl'
require 'base64'
module Cipher
def self.encrypt(key, data)
data += 'A' # Add 'A' suffix to support empty data
cipher(:encrypt, key, data)
end
def self.decrypt(key, text)
data = cipher(:decrypt, key, text)
data[0...-1] # Remove the 'A' suffix
end
def self.encrypt_base64(key, data)
blowfish_string = self.encrypt(key, data)
Base64.encode64(blowfish_string)
end
def self.decrypt_base64(key, base64_string)
blowfish_string = Base64.decode64(base64_string)
self.decrypt(key, blowfish_string)
end
private
def self.cipher(mode, key, data)
cipher = OpenSSL::Cipher::Cipher.new('bf-cbc').send(mode)
cipher.key = Digest::SHA256.digest(key)
cipher.update(data) << cipher.final
end
end
Run Code Online (Sandbox Code Playgroud)
然后我创建了以下spec文件.
require 'rails_helper' …Run Code Online (Sandbox Code Playgroud) 我有一些页面在URL中加载了哈希/锚点.当我们这样做时,它会拧紧文档的填充/边距.没有它,它工作正常.更奇怪的是,如果我使用浏览器工具来获取css并禁用边距和填充然后重新启用它,它看起来很好.我们正在使用第三方网站为我们的网站提供服务,这意味着我们已经被锁定在CMS类型的服务中,并且我们的手在一定程度上与我们可以自定义页面的程度有关.因此,我们引用了多个css文件,依此类推.如果您查看下面的两个网址,您会在网址末尾附加#company_settings的网址中看到问题.如果你然后使用chrome中的inspect元素来查看标题并禁用并重新启用custom.css:2作为边距和填充,你会看到它然后修复问题.知道为什么会这样,如果有什么我可以用css来解决这个问题吗?谢谢.
http://www.patriotsoftware.com/patriot-pay-help-center-payroll-settings
VS
http://www.patriotsoftware.com/patriot-pay-help-center-payroll-settings/#company_settings
我不想从 vite build 获取像 index.abc123.js 这样的默认输出 js 文件,而是想告诉它如何命名输出文件。但我不知道该怎么做。这是我当前的 vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
server: {
watch: {
usePolling: true
}
},
build: {
emptyOutDir: true,
outDir: '../public',
assetsDir: './dist',
}
})
Run Code Online (Sandbox Code Playgroud)
更新:花了相当多的时间来弄清楚什么适合我们的文件夹结构,但我终于找到了如何做我正在寻找的事情。这是我们最终的 vite.config.js 和packages.json 希望它对其他人有帮助。
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig(({ command, mode }) => ({
plugins: [vue()],
server: {
watch: {
usePolling: true
}
},
build: {
emptyOutDir: true,
outDir: '../public', …Run Code Online (Sandbox Code Playgroud) 我有一个下拉(dropdown2),如果有内容,它是必需的,但它的选项数据是由另一个下拉(dropdown1)选择的ajax驱动的.有时dropdown2将为空,在这种情况下我不能要求它.所以我可以requiredFieldValidators通过调用这个来禁用javascript中的...
ValidatorEnable(document.getElementById(validatorId), false);
Run Code Online (Sandbox Code Playgroud)
这工作正常但服务器仍然触发requiredFieldValidator逻辑.是否有人知道如何强制服务器不验证验证器是否设置为false客户端?
使用带有期望 json 帖子的方法的控制器,例如...
public class MyController : Controller
{
[HttpPost]
public ActionResult PostAction()
{
string json = new StreamReader(Request.InputStream).ReadToEnd();
//do something with json
}
}
Run Code Online (Sandbox Code Playgroud)
当您尝试测试时,如何设置单元测试以将发布数据发送到控制器?
我正在尝试测试此控制器方法,以确保它重定向到另一个控制器方法或存在模型错误。
public IActionResult ResetPassword(ResetPasswordViewModel viewModel)
{
if (viewModel.NewPassword.Equals(viewModel.NewPasswordConfirm))
{
...do stuff
return RedirectToAction("Index", "Home");
}
ModelState.AddModelError("ResetError", "Your passwords did not match. Please try again");
return View(viewModel);
}
Run Code Online (Sandbox Code Playgroud)
当我运行测试时,我收到两条不同的错误消息。当它尝试 RedirectToAction 时,我收到错误...
System.InvalidOperationException : No service for type 'Microsoft.AspNetCore.Mvc.Routing.IUrlHelperFactory' has been registered.
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.AspNetCore.Mvc.ControllerBase.get_Url()
at Microsoft.AspNetCore.Mvc.ControllerBase.RedirectToAction(String actionName, String controllerName, Object routeValues, String fragment)
at Microsoft.AspNetCore.Mvc.ControllerBase.RedirectToAction(String actionName, String controllerName, Object routeValues)
at Microsoft.AspNetCore.Mvc.ControllerBase.RedirectToAction(String actionName, String controllerName)
Run Code Online (Sandbox Code Playgroud)
当它尝试返回视图时,错误消息是...
System.InvalidOperationException : No service for type 'Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory' has …Run Code Online (Sandbox Code Playgroud) 我有一个我在Windows Server 2003上使用的程序,它在IIS6中设置了一个我过去没有遇到任何问题的站点.
我正在尝试使用Windows 2008 Server Web SP2做同样的事情,我收到了一个错误.我猜它与用户帐户安全性有关.如果这是正确的,有没有办法解决这个问题?谢谢.
System.Runtime.InteropServices.COMException (0x80070005):
Access is denied. at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
Run Code Online (Sandbox Code Playgroud)
编辑:
我发现Microsoft提供了一个程序集,Microsoft.Web.Administration使IIS7的任务更容易.但是,当我运行应用程序时,我收到一个错误.报告的错误说:
"指定的HTTPS绑定无效".
我没有指定https绑定,所以我不知道为什么我收到错误消息.这是代码.
using Microsoft.Web.Administration;
....
using (ServerManager iisManager = new ServerManager())
{
iisManager.Sites.Add(site.Name.ToString(), "http", "*:80:" + domain,
server.InetPath + site.Name);
iisManager.CommitChanges();
Site newSite = iisManager.Sites[site.Name];
newSite.Applications[0].ApplicationPoolName = "TrialUsers";
iisManager.CommitChanges();
}
Run Code Online (Sandbox Code Playgroud)
此外,此任务必须更新Web场中的多个服务器.有谁知道如何修改代码来实现这一目标?
在我的控制器中,我有以下 before_action...
def cors_set_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
headers['Access-Control-Request-Method'] = '*'
headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
end
Run Code Online (Sandbox Code Playgroud)
我正在尝试编写一个测试以确保使用以下代码设置这些标头...
describe 'cors headers action ' do
it 'sets the proper headers' do
get :jobs, format: :json
p response.headers
expect(response.headers['Access-Control-Allow-Origin']).to eq('*')
expect(response.headers['Access-Control-Allow-Methods']).to eq('POST, PUT, DELETE, GET, OPTIONS')
expect(response.headers['Access-Control-Request-Method']).to eq('*')
expect(response.headers['Access-Control-Allow-Headers']).to eq('Origin, X-Requested-With, Content-Type, Accept, Authorization')
end
end
Run Code Online (Sandbox Code Playgroud)
当我做 p response.headers 时,唯一返回的标题是 - {"X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"1; mode=block", "X-Content- Type-Options"=>"nosniff", "Content-Type"=>"text/html; charset=utf-8"}
这在我的应用程序中运行良好,但不适用于测试。那么,知道可能是什么问题吗?谢谢。
c# ×4
asp.net-core ×2
unit-testing ×2
ajax ×1
asp.net ×1
asp.net-mvc ×1
css ×1
iis-7 ×1
jquery ×1
rspec ×1
rspec-rails ×1
validation ×1
vite ×1