Base solution for your next web application

Activities of "alukaszewski"

Answer

Hikal,

Could you please provide a basic code example for an Mpa page controller, that is able to use the SettingManager.GetSettingValue method and return a value to the client.

For example, here is a very basic controller that returns a string;

using Abp.Configuration;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MyProject.Web.Controllers
{
    public class HelloWorldController : Controller
    {
        public string Index()
        {
            return "Hello World!";
        }
    }

}

How do I make that return a stored setting string, such as the SMTP Host? I thought I would be able to simply use the SettingManager.GetSettingValue before returning the value, but I cannot understand how.

Thanks.

Answer

... and if I try

var value1 = SettingManagerExtensions.GetSettingValue("MyValue")

Then although I get to see/choose the .GetSettingValue method, I get error "No overload for method 'GetSettingValue' takes 1 arguments"

So I'm baffled.

Answer

Further, if I try;

var value1 = Abp.Configuration.SettingManager.

Then I only get '.ApplicationSettingsCacheKey', 'Equals' and 'ReferenceEquals' methods. Weird.

Answer

Yes that is exactly what I am trying, it should be simple.

using Abp.Configuration;
var value = SettingManager.GetSettingValue("YOUR_SETTING_NAME");

results in VS build failure due to:

'SettingManager' does not contain a definition for 'GetSettingValue'.

The GetSettingValue is highlighted in the VS editor as that cannot be found as a method/whatever of SettingManager.

I am using Mpa.

If I look at the inbuilt Mpa/Controllers/SettingsController.cs, I get more extension methods when I try var value = SettingManager.

I get .GetSettingValueAsync, .GetSettingValueForApplicationAsync etc.

Are you sure I only need using Abp.Configuration? I can see that the SettingsController.cs has the following;

using System.Threading.Tasks;
using System.Web.Mvc;
using Abp.Configuration.Startup;
using Abp.Web.Mvc.Authorization;
using MyProject.Authorization;
using MyProject.Configuration.Tenants;
using MyProject.Web.Controllers;

Do I need to any of those? I did try some but still I do not have the .GetSettingValue extension method when I try SettingManager.

Thanks,

Andy

Question

I have added some additional settings to general and can successfully set and store these in the database. I just duplicated how the WebSiteRootAddress setting worked.

If I have a controller, how do I retrieve a setting? I have tried having "using abp.configuration;" at the top of the controller, and trying something like

var value2 = SettingManager.GetSettingValue("somestoredsetting");

results in VS showing "'SettingManager' does not contain a definition for 'GetSettingValue'".

What am I missing? Do I need to use the @Model method of code that the Settings.cshtml page uses to retrieve settings?

It's OK, I've figured out I had to remove the jstree.min.css from the .csproj file. I must have missed that one when I removed all the other .min.css files.

Andy

Hi,

When I publish Release to IIS, I am missing the jstree layout style/checkboxes when I view Roles/Permissions. OK when using local VS IISExpress debug. Is this another bundle config issue?

Answer

Aha! Found what I wanted. It was in the RoutConfig.cs, I changed:

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            namespaces: new[] { "Callisto.Web.Controllers" }
            );

to:

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional },
            namespaces: new[] { "Callisto.Web.Controllers" }
            );

So many places to find things hidden away!

Andy

Answer

OK, maybe I asked my question incorrectly.

When I access my published site in IIS, how do I have it start with the Login page instead of the default "Home page" page? My Startup.cs is already set with LoginPath = new PathString("/Account/Login").

So, basically, I want the project to start with the Account Controller and not the Home Controller? Does that make sense?

Question

Hi, where do I configure to have the Mpa application start with the /Account/Login page? If I tick the 'remember me' option, should it then also take me straight into dashboard or still present the login page? Also, I am using Mpa only, so what sections/folders within Visual Studio can I safely remove from my project?

Showing 41 to 50 of 65 entries