Base solution for your next web application

Activities of "deventerprise"

[Route("api/[controller]/[action]")]
public class MyController : MyAppControllerBase
{
        [HttpGet]
        [DontWrapResult]
        [AbpAuthorize]
        public IActionResult GetSomething()
        {
            ...
            return Ok(someData);
        }
        
        [HttpPost]
        [DisableValidation]
        [AbpAuthorize]
        public IActionResult CreateSomething([FromBody] InputDto model)
        {
            return Ok();
        }
}

I'm creating a new API controller for a client to use, I want to disable the built-in error handling for bad parameters (so that I can return a 400 - Bad Request instead of a 500) and also need to prevent any results from being wrapped inside a result property.

I've tried [DisableValidation] and [DontWrapResult] on the controller as well as the controller methods but it does not seem to have any effect. How can I do this otherwise?

@exInt: to fix the missing customzations issue in the release build you'll need to add the files to the bundle config, seems like someone missed this configuration: https://support.aspnetzero.com/QA/Questions/6282#answer-79e97d62-653d-e621-96cc-39eb621f2e19

This is a problem with the bundle config that does not minify the customization files: https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/bundleconfig.json

You need to bundle the base on as well as all the all the themes:

  {
    "outputFileName": "wwwroot/Common/Styles/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/default/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/default/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/blue/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/blue/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/green/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/green/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/pink/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/pink/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/yellow/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/yellow/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/theme2/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/theme2/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/theme3/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/theme3/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/theme7/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/theme7/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/theme8/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/theme8/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/theme11/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/theme11/metronic-customize.css"
    ]
  }

And also remove the main customzation from the common-styles.css bundle at the top:

  {
    "outputFileName": "wwwroot/view-resources/Areas/App/Views/_Bundles/common-styles.css",
    "inputFiles": [
      "wwwroot/Common/Styles/**/*.css",
      "wwwroot/fonts/fonts-poppins.css",
      "wwwroot/fonts/fonts-roboto.css",
      "!wwwroot/Common/Styles/**/*.min.css",
      "!wwwroot/Common/Styles/Themes/**/*.css",
      "!wwwroot/Common/Styles/abp-zero-template-rtl.css",
+    "!wwwroot/Common/Styles/metronic-customize.css*.css",
      "!wwwroot/Common/Styles/metronic-customize-top-menu*.css"
    ]
  },

That just leaves the JS error "Invalid dimensions for plot" on the dashboard to try and resolve.

This is the same problem as seen here: https://support.aspnetzero.com/QA/Questions/6194#answer-f37480ee-3374-e2de-e53f-39eb1a9bcef4

Minified versions of these files don't exist and are not created as part of a production build. Some of the theme files are not empty so you should not remove them.

Figured out you need to set the Abp.TenantId header: https://support.aspnetzero.com/QA/Questions/6269

OK, I cannot seem to register users if they pass in the tenant ID.

CurrentUnitOfWork.SetTenantId(model.TenantId);

var user = await _userRegistrationManager.RegisterAsync(
    model.Name,
    model.Surname,
    model.EmailAddress,
    model.PhoneNumber,
    model.Password,
    false,
    _appUrlService.CreateEmailActivationUrlFormat(model.TenantId)
);

user.PhoneNumber = model.PhoneNumber;
user.ShouldChangePasswordOnNextLogin = false;

await CurrentUnitOfWork.SaveChangesAsync();

I rexpected the above to work, but instead I get an exception saying "InvalidOperationException: Can not register host users!".

CheckForTenant() in UserRegistrationManager only checks the session, not the unit of work and since this value cannot be set, how do I set in in an unauthorized Register call?

Experiencing two obvious issues when publishing the application live, these do not occur during development.

  1. A CSS file fails to load (metronic-customize.min.css). It seems like a minified version of the origial file is not created. There are two that are trying to get loaded, /Common/Styles/Themes/default/metronic-customize.min.css and /Common/Styles/metronic-customize.min.css
  2. The default dashboard does not load correctly with te JS error in host-dashboard-libs.min.js "Uncaught Error: Invalid dimensions for plot, width = 745.313, height = 0"

These occured in version 6.4 and still after updating to 6.5. Are these known issues?

I just finished it up now. Was a little tricky to get it right but your advice did help put on the right track as to what I needed to do. Tested everything works in terms of logging in even with the wrong cookie and impersonation.

Was confused about the logins being created but made some other tweaks there to identify tenant admins a bit better so that I could use phone number user names (off-topic). For anyone else reading, those users are also required for unit tests so don't just remove that code.

Figured out why the admin users get created, this is because if a user with "admin" does not exist then one is created for you. This happens in TenantRoleAndUserBuilder.cs inside CreateRolesAndUsers. during startup.

More users are created automatically in HostRoleAndUserCreator.cs inside CreateHostRoleAndUsers, also removed this to avoid it.

Showing 21 to 30 of 32 entries