c# – Feedback requested for declaring webmethods in UserControls

I know it’s not possible to define a WebMethod in a user control. Typically you define a WebMethod on the Page class where the user control is dropped and somewhere in the Page’s code behind you see something like this…


Public Class SomePage
  Inherits Page

  Public Shared Function MyWebMethod(someObject As MyObject) As Results
    ... do some work ...
    Return someObject.SomeFunctionThatDoesSomething()
  End Function
End Class

However, lately, I find myself doing this…note the filenames


Public Class MyUserControl
  Inherits UserControl
End Class

Partial Public Class SomePage
  Public Shared Function MyWebMethod(someObject As MyObject) As Results
    ... do some work ...
    Return someObject.SomeFunctionThatDoesSomething()
  End Function
End Class

I like how this keeps the webmethods with the user control code instead of the individual pages. And it allows me to keep an “inventory” so to speak of pages using the code.

I also like how it sort of resolves the issue that “you can’t define a webmethod in a user control”

Now just to clarify, all my user Controls files are compiled with the main website and are not intended to be used anywhere else.

I would just like some opinions/criticism on using partial classes like this.
In all the years I’ve been using SO and researching user controls and WebMethods I’ve never come across this style of declaration.
It works, it suits my needs, but the fact that I’ve never seen it done has me questioning myself.

http request – Erro “No ‘access-control-allow-origin’ header is present on the requested resource.”

Recentemente encontrei um problema ao tentar consumir minha própria API .Net Core 3.1 (em produção) utilizando Angular 9.

O problema era que os requests GET ou POST funcionavam perfeitamente, mas ao tentar consumir por requisição em PUT ou DELETE recebia o erro:

Encontrei uma solução que envolvia alterar o meu web.config da API incluindo as linhas

  <remove name="WebDAVModule" />
    <add name="X-Frame-Options" value="DENY" />
    <add name="Access-Control-Allow-Methods" value="*" />
    <add name="Access-Control-Allow-Headers" value="*" />
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <remove name="OPTIONSVerbHandler" />
  <remove name="TRACEVerbHandler" />
  <remove name="WebDAV" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

Ao incluir as linhas acima, o request realmente funcionou. Então fui retirando linha por linha da solução apresentada acima e testando a requisição, até que percebi que para resolver o problema da requisição bastava adicionar parte do código no web.config:

  <remove name="WebDAVModule" />

Eu queria realmente entender o motivo por trás disso, afinal eu configurei o CORS da minha API para aceitar qualquer Origin, Header ou Method e acho muito estranho ter que resolver isso alterando diretamente o meu web.config.

Alguém saberia me explicar o motivo deste problema e se existe uma melhor solução (de preferência que seja diretamente no código da minha API)?

event subscribers – Intercepting when a page is requested

I am trying to call a function every time a page is loaded. With Drupal 7, I used hook_init, now I’m using a subscribed event.

  public function logRegEntry(GetResponseEvent $event) {
    $request = $event->getRequest();
    $method = $request->getMethod();
    $path = $request->getPathInfo();
    $route_name = Drupal::routeMatch()->getRouteName();
    if (($method == 'GET') && ($path == '/')) {
      // do it just for this module

This works fine for the home page, but I want it for every page a user requests. This is getting called four times; first for the page I’m requestings, and then for:

I did notice that on the first request, the $route_name is set to “entity.node.canonical” — might this be a better way to check for a page? Probably not, since it would only get triggered by node pages.

I’m looking for a better way to do this, not sure why there are four request events. Thanks.

magento2 – magento/composer-root-update-plugin is locked to version 1.0.0 and an update of this package was not requested

i am trying to install the extension through composer but i am getting below error.

Your requirements could not be resolved to an installable set of packages.

Problem 1
– magento/composer-root-update-plugin is locked to version 1.0.0 and an update of this package was not requested.
– magento/composer-root-update-plugin 1.0.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
Problem 2
– dealerdirect/phpcodesniffer-composer-installer is locked to version v0.5.0 and an update of this package was not requested.
– dealerdirect/phpcodesniffer-composer-installer v0.5.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
Problem 3
– laminas/laminas-dependency-plugin 1.0.4 requires composer-plugin-api ^1.1 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
– magento/product-community-edition 2.4.0 requires laminas/laminas-dependency-plugin ^1.0 -> satisfiable by laminas/laminas-dependency-plugin[1.0.4].
– magento/product-community-edition is locked to version 2.4.0 and an update of this package was not requested.

You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.

For more information please find the below image.
enter image description here

sending – What does “Uneconomical UTXO requested” mean?

This error message seems to indicate that one of the Unspent Transaction Outputs (UTXO) in your wallet has a lower value than the cost of spending it.

In Bitcoin, funds are tracked in the form of distinct transaction outputs. Each time someone gets paid, at least one new transaction output is created. While your wallet may show your funds as a balance, under the hood the balance is actually composed of one or multiple UTXO. To spend a UTXO, an input is added to a transaction. Transaction fees are paid per byte of data. If an input for example used 148 bytes, and the current feerate were 100 satoshi per byte, it would cost 14,800 satoshi to spend a UTXO. If the UTXO’s value was 5,897 satoshi, it costs more to spend it than its value— it is uneconomic to spend it.

You may be able to sidestep the error by setting a lower feerate. Note that this will likely cause the transaction to take a long time to confirm.

Altogether, it would be reasonable for your wallet software to filter uneconomic UTXO in the preselection, so you may want to consider reporting this as a UX bug.

Use Apache as Proxy and to Rewrite Requested Host

I am trying to use an Apache server for two very limited purposes. There is a single, dedicated device (Black Box) on a local network which makes calls to a remote original.host.com. I wish to use Apache on this local network as a proxy that will also substitute my.newhost.com for original.host.com when Black Box requests service. The Black Box allows me to specify a proxy server but does not allow me to change its target host for the HTTP service requests.

Black Box makes only two very specific requests:

which I wish to change to:

Using .htaccess I am successfully able to configure Apache as a proxy so this function works.

I have tried using the following rewriteRule (as well as many variations) to substitute my.newhost.com for original.host.com, but I can’t seem to get Apache to actually make the substitution:

LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine on
RewriteCond %{HTTP_HOST} original.host.com
RewriteRule   ^(.*)  http://my.newhost.com/$1

Does anyone have any idea what I might be doing wrong?

sql server – DBCC CheckDB : Operating System Error 27(The drive cannot find the sector requested)

So my regular DBCC check had this lovely message waiting for me in the error logs this morning. I’ve been trying to find out more about this issue and what can be done about it. Manually running DBCC CHECKDB will result in DBCC aborting with Error 6 (connection closed by remote host) and get me this error in the SQL log file. Running DBCC CHECKDB(dbname) WITH PHYSICAL ONLY or DBCC CHECKDB(dbname, NOINDEX) will complete successfully and report no errors. Chkdsk reports no errors on the drive.

How can I determine if this a corruption error in the database file or an actual “on the disk” bad sector? Can this be fixed in place or do I need a new disk and to restore from backups? While I have good backups, if I restore a recent backup, will that also “restore” the missing data/sector?

FWIW the DB is 2.2 TB so I’m rather reluctant to jump into a fix until I really know what’s going on.

Cannot assign requested address in Docker .NET Console client application

I am trying to learn some docker, i managed to setup API image/container and it works fine, I can get response from the API when i’ll go through web browser. However my console client can’t get a request to my API and I am not sure why. The only error i get is Cannot assign requested address in docker CLI.

class Program
    static HttpClient client = new HttpClient();
    static string apiUrl = "http://localhost:8080";

    static void Main()
        System.Console.WriteLine("Console started.");

    static async Task RunAsync()
        // Update port # in the following line.
        client.BaseAddress = new Uri("http://localhost:64195/");
            new MediaTypeWithQualityHeaderValue("application/json"));

            var value = await GetValueAsync();

And the method that generate the error:

static async Task<Value> GetValueAsync()
        Value value = null;

         HttpResponseMessage response = await client.GetAsync(apiUrl + "/value");
         if (response.IsSuccessStatusCode)
             value = await response.Content.ReadAsAsync<Value>();
         return value;

Program stops and returns an error on the client.GetAsync line, it never gets to the writeline(“TEST”). Anyone knows what could be the problem? Everything else works until the request. On the request the Cannot assign requested address shows up and stops the container/program.

the requested range does not exist in the sheet

When i’m trying to open an excel File in Excel Online, i get this error!
“the requested range does not exist in the sheet”

I can’t open the file.

How i can fix it please?

Want to upgrade to Mac OS High Sierra and it shows MediaKit reports not enough space on device for requested operation

Trying to update my MacBook from os El Capitan to High Sierra on reboot it shows MediaKit reports not enough space on device for requested operation