How to override the login page provided by abp.io? - authentication

I tried to override my custom login with LoginModel and Login.cshtml as described here.
After replacing Login.cshtml and myCustomeLoginModel.cs, this error is shown :
'LoginModel' does not contain a constructor that takes 2 arguments
and this is the code of myCustomLoginModel.cs after replacing :
public class myCustomLoginModel: LoginModel
{
public myCustomLoginModel(IAuthenticationSchemeProvider schemeProvider,
IOptions<Volo.Abp.Account.Web.AbpAccountOptions> accountOptions)
: base(schemeProvider, accountOptions)
{
}
}
and then all properties of myCustomLoginModel is not recognized in Login.cshtml like this :
The properties of myCustomLoginModel is not recognized
What did I miss ?
I tried to send any text for #hikalkan, the contributor of this concept at abp.io, but I did not found any email or contact info that I can use.

I found that I had a fault!
I had created a class named 'LoginModel.cs' under the Login.cshtml.
I don't know how this happened.
But this causes errors.
If I followed exactly what was in the document, it would work nicely!

Related

dotnetcore asp understand Inconsistent accessibility

I am new to dotnetcore so please be patient...
this ASP controller method works if I give back a list of Strings.
[HttpGet]
public List<Contract> Get()
{
return getContracts();
}
meanwhile every thing is public...it's just later where I see the error
If I return a list of very simple objects I get the warning
Inconsistent accessibility: return type 'type' is less accessible than method 'method'
the documentation for that error only shows an example for that. But how to fix it ?
Also thanks for any Link/Hint to understand the issue/rules here !
If your class is defined as:
class Contract
{
}
Then you will get the error because a class is internal by default.
A public method on a public class can't return internal types.
So we make the class public:
public class Contract
{
}

Use a #typeparam as component in Blazor

Is it possible to use a #typeparam as Component?
More explicitly, do something like the following MyComponent.razor:
#typeparam TComponent
<TComponent />
Of course, there would also be a MyComponent.razor.cs file whose content would be:
public partial MyComponent<TComponent> : ComponentBase where TComponent : ComponentBase
so that the compiler would know that <TComponent /> is meaningful.
I cannot find any documentation about this in Microsoft docs.
When I try it seems to compile, but display the following warning:
warning RZ10012: Found markup element with unexpected name 'TComponent'. If this is intended to be a component, add a #using directive for its namespace
However it is only a warning and not an error. It does't show anything in the browser though.
I am using ASP.NET 5.
Thanks
Not quite sure what you are trying to do but you can write what I believe you are trying to achieve as a component class like this:
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Rendering;
namespace BlazorTest.Pages
{
public class ComponentRenderer<TComponent> : ComponentBase where TComponent : IComponent
{
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
builder.OpenComponent<TComponent>(1);
builder.CloseComponent();
}
}
}
So in Index.razor you can do something like the following to render a component of type FetchData:
....
<ComponentRenderer TComponent="FetchData"></ComponentRenderer>
....
If I'm wide of the mark post a little more information.

Managing the Scope of a TagHelper

Reading and learning about TagHelpers from a book so I wrote and used a TagHelper.
Writing it:
public class ButtonTagHelper: TagHelper
{
public string BsButtonColor { get; set; }
public override void Process(TagHelperContext context, TagHelperOutput output)
{
output.Attributes.SetAttribute("class", $"btn btn-{BsButtonColor}");
}
}
and then using it in Razor like this:
<button bs-button-color="danger" type="submit">ADD</button>
OK I learned that much. Now in the next section about scopes it is saying:
which confuses me and I don't understand it. WHY? In my code above I didn't say apply it to all buttons. Where did that get from?
My understanding was that it looks at bs-button-color so if another button declaration in Razor doesn't have that, why would it be a problem?
OK went back to start of the chapter and read it again. Here is the convention I had missed reading it in round one:
The NAME of the TagHelper combines the name of the element it transforms followed by the word TagHelper.
and in my example the class is called ButtonTagHelper so it means it wants to apply it to BUTTONS

struts2: select tag doesn't like beans with "parameters" property?

I have a base class ReportElement which has type property:
public abstract class ReportElement {
private ReportElementType type;
public ReportElementType getType() {
return type;
}
public void setType(ReportElementType type) {
this.type = type;
}
}
ReportElementType is just an enum with specified code and i18nKey properties for each element. I have a couple of subclasses of ReportElement, each of them introducing their own properties. One of them is Plot:
public class Plot extends ReportElement {
public Plot() {
setType(ReportElementType.PLOT);
}
private Collection<Parameter> parameters = new ArrayList<Parameter>();
public Collection<Parameter> getParameters() {
return parameters;
}
}
On some page I needed to display a collection of different ReportElement instances, so I just used struts2 select tag:
<s:select list="myElements" listKey="type.code" listValue="type.i18nKey" size="20"/>
This worked like a charm for every element except for Plot instaces. Instead of invoking getType().getCode() or getType().getI18nKey() plain toString() was invoked on every instance of Plot! After several hours of fun debugging I noticed that during tag evaluation Plot's getParameters() method is called! So it seems struts was trying to evaluate type.code and type.i18nKey using getParameters() method! Failing to do that it ignored the existence of the properties, that I have clearly specified for usage!
After renaming getParameters to a kind of odd name like getParamms the problem gone. Also the problem hasn't occured when using iterator tag together with property tag instead of select tag.
Does anyone have an idea WHY struts select tag uses parameters property of my bean, when I have clearly specified what property should be used? Is it some "cool" feature or a bug?
P.S. I use struts 2.2.3.1
The argument used in all the FreeMarker templates representing a tag's parameters is called parameters. By providing a parameters property that takes precedence, S2 was unable to get to the object on the stack containing the tag's parameters.
It's neither a cool feature nor a bug, it's just how the templates are implemented. Checking the template source may have saved the few hours of debugging.
Found corresponding issue in struts JIRA: https://issues.apache.org/jira/browse/WW-3268
2.3 is specified as fix version.

MEF Error message

Can anybody explain this error message:
The composition remains unchanged. The
changes were rejected because of the
following error(s): The composition
produced a single composition error.
The root cause is provided below.
Review the CompositionException.Errors
property for more detailed
information.
1) No valid exports were found that
match the constraint
'((exportDefinition.ContractName ==
"Silverbits.ApplicationServices.ApplicationServicesManager")
AndAlso
(exportDefinition.Metadata.ContainsKey("ExportTypeIdentity")
AndAlso
"Silverbits.ApplicationServices.ApplicationServicesManager".Equals(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))',
invalid exports may have been
rejected.
Resulting in: Cannot set import
'Silverbits.Applications.SilverbitsApplication.ApplicationServices
(ContractName="Silverbits.ApplicationServices.ApplicationServicesManager")'
on part 'Framework.App'. Element:
Silverbits.Applications.SilverbitsApplication.ApplicationServices
(ContractName="Silverbits.ApplicationServices.ApplicationServicesManager")
--> Framwork.App
While the ApplicationServicesManager class may be available and marked with an [Export] attribute, this part may still have been rejected because it has itself imports which cannot be satisfied.
Take a look at the section Diagnosing Composition problems in the MEF documentation.
It's looking for something like this:
[Export]
public class ApplicationServicesManager
{
}
or like this:
public class SomeClass
{
[Export]
public ApplicationServicesManager AppServices { get; private set; }
}
But it can't find one in the scope of your provided exports. If you're Exporting it from a property or field, make sure the object exporting it has been composed with the container. If it's a class export and the class is present in another assembly, make sure the assembly is in the container's catalog.