Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Tomáš Herceg
    @tomasherceg
    @anup.chaturvedi_gitlab Wow, it's great that you've found the problem. I was running out of ideas about what could cause this behavior. :-)
    dima-chernin
    @dima-chernin
    Hi, guys.. maybe a dumb question, but is there a standard way to rerun validation? Sort of TryValidateModel?
    dima-chernin
    @dima-chernin
    I've tried to play with ModelState and fill it with errors, but what I need is to highlight the invalid fields on page first load. Not only on PostBack
    kevinjmackey
    @kevinjmackey
    image.png
    image.png
    Hello, I found Dotvvm and like it as an antidote to js/ts-heavy font-end frameworks. I'm trying to work with REST APIs but am having trouble getting off the ground. The environment is Visual Studio 2019, Dotvvm 2.4.0.1 (from the NuGet package manager), .netcore 3.1 and I get the above (sorry, pasted twice) when I try the dotnet dotvvm command line. The error is the same whether I am trying to ingest the swagger json or the above command. I have also tried running the command from within the VS2019 command prompt. What stupid thing am I doing/missing?
    Stanislav Lukeš
    @exyi
    Hi @kevinjmackey, I guess you don't have the dotvvm tool installed - you need to install the https://www.nuget.org/packages/DotVVM.CommandLine package. Either globally (as suggested on NuGet website), or you can install it only into a specific project, see https://www.dotvvm.com/docs/tutorials/advanced-dotvvm-command-line/2.0
    Hi @dima-chernin, sorry for a late reply, but I'm not aware of any method to initialize the ModelState on load. Maybe, you could run a postback immediately after loading the page (for example, click on a hidden button). Postback are usually quite costy, but if fails on the client-side validation, it won't do any request to the server.
    Tomáš Herceg
    @tomasherceg
    @exyi @dima-chernin This is btw a great feedback for DotVVM 3.0 - we plan to introduce an option to return validation errors with a successful postback response, so we can extend this to the initial page load as well. I'll tell the guys.
    dima-chernin
    @dima-chernin

    Maybe, you could run a postback immediately after loading the page (for example, click on a hidden button).

    @exyi , this was exactly what I had to do )

    dima-chernin
    @dima-chernin
    actually it was quite rare scenario (imported partially wrong data, which had to be correctly filled), so the postback was triggered only for the entities in specific state and the impact of postback was minimal
    kevinjmackey
    @kevinjmackey
    @exyi Many thanks. I knew I had to be missing something. All good now
    Andreas Doll
    @dollhaus
    I don't need the runat="server" attribute in dotvvm, do I?
    Tomáš Herceg
    @tomasherceg
    @dollhaus No, there is no need for it. :-) We have a quick cheat-sheet for Web Forms developers: https://www.dotvvm.com/webforms
    Andreas Doll
    @dollhaus
    Oh cool, I didn't know about that
    OOI, what if I don't want to expose the session to the user? Can I still use HttpContext.Current.Session?
    Oh, nvm I found a solution
    Anup Chaturvedi
    @anup.chaturvedi_gitlab
            Hi @tomasherceg ,
            I am trying to create a PDF file and then Download the same. I am using ReturnFile method but the file is not getting downloaded. 
            I am getting following error when using ReturnFile extension method:
    
            Error: Request interrupted: ReturnFile (FileName.pdf)
    
            I have done follwoing 
    
            -in the View Model:
    
            Context.ReturnFile(file.GetBytes, FileName.pfd, "application/pdf");
    
            -in DotVVM file in the ConfigureServices method:
    
            options.AddDefaultTempStorages("temp");
    
            I can see that two files are getting generated in the temp\returnedFiles folder with with extension data and metadata. 
    
            Please suggest.
    Tomáš Herceg
    @tomasherceg

    @anup.chaturvedi_gitlab Is there a try/catch block around the ReturnFile? If it is, can you try to add this catch clause to it?

    } catch (DotvvmInterruptRequestExecutionException) {
        throw;
    } catch ...

    DotVVM throws this exception from ReturnFile (and then catches it in the runtime) and unfortunately, it doesn't work properly if you "eat" this type of exception. The same exception is used when you are doing redirects - you also need to re-throw the exception so the redirect works correctly.

    Anup Chaturvedi
    @anup.chaturvedi_gitlab
    @tomasherceg : Thanks , the download started working now.
    MichalOberreiter
    @MichalOberreiter
    Hi guys, anyone already running DotVVM website on linux (debian) with apache? Everything seems to work fine, except unhandled exceptions on postback. Response return correctly HTTP status 500, but response is completely empty. Other responses with status 200 works, redirects works... Anyone solved this? Thx for answer
    David Najman
    @dnajcz
    Zdravím, rád bych si rozběhal DotVVM pod Mac OS, což by asi mělo být možné, ale nejde mi to. Mám nainstalované Visual Studio for Mac Community (8.7.8), aplikace s DotVVM mi tam běží, ale soubory .dothml jakoby VS vůbec neznalo (nerozlišuje barevně žádné tagy apod.), samozřejmě nefunguje intallisense atd. Zkoušel jsem využít příkaz, který uvádíte: "dotnet new --install DotVVM.Templates::", ale ten nefunguje, vypíše chybu: "no matches found: DotVVM.Templates::". Můžete mi prosím poradit, co dělám špatně? Mám licencni DotVVM, kterou bych rád prodloužil, ale optimálně bych ji chtěl využít na Macu. Díky...
    ...oprava: utekla mi tam hvězdička v tom komentáři výše, ale použil jsem opravdu celé: "dotnet new --install DotVVM.Templates::" včetně hvězdičky na konci. Vypíše to chybu: no matches found: DotVVM.Templates::.
    David Najman
    @dnajcz
    (aha, tu hvězdičku mi maže ten Gitter, co nic. prostě tam je :)
    Andreas Doll
    @dollhaus
    I'm looking to add some HTML to the page based on a method that gets called before the HTML is rendered. However, I can't seem to use a method when using the value attribute in the HTML control. Should I be using a plain string, and setting it in page.init() or page.load() instead?
    <dot:HtmlLiteral Html="{value: BannerHTML()}" />
    public string BannerHTML ()
            {
                bannerTemplates templateModels = new bannerTemplates();
                bannerHTMLTemplate template = templateModels.randomTitle();
                return template.TemplateHTMLString();
            }
    Sorry, I feel like that's a stupid question but brain fog is real
    Andreas Doll
    @dollhaus

    So I changed my approach and went with this:

    public string BannerHTML => bannerString();
    string bannerString ()
            {
                bannerTemplates templateModels = new bannerTemplates();
                bannerHTMLTemplate template = templateModels.randomTitle();
                return template.TemplateHTMLString();
            }

    I'm a bit confused as to why I need the extra step, though. Is the assignment explicitly converted to javascript?

    Tomáš Herceg
    @tomasherceg
    @dollhaus Methods in the value binding are not supported - the viewmodel needs to be serialized into JSON and sent to the browser where the application is running. There is no way to serialize a method, so you need to "call" it on the server and place the result in a viewmodel property.
    If the HTML is "static" and never changes, you can do a trick with resource binding - if you use {resource: BannerHTML()}, it will call the function when the page is being rendered, and it will place the HTML as if it was hard-coded in the markup. It can help with some scenarios, but if you need to update the HTML when the page is loaded and user interacts with it, you need to use the value binding.
    @dnajcz Visual Studio for Mac bohužel naše extension nepodporuje - máme extension pro VS Code, která nabízí základní funkce, ale Mac zatím neumíme.
    Jinak u těch templates zkuste jen prosté dotnet new --install DotVVM.Templates - ty dvojtečky dříve fungovaly a teď nejdou, nepovedlo se mi zjistit, proč.
    Tomáš Herceg
    @tomasherceg
    @MichalOberreiter I think that the error page is used only in the Development mode. Do you run the project using dotnet run or dotnet YourApp.dll? In the second case, I think you'll need to set up the ASPNETCORE_ENVIRONMENT variable to Development to see the error page.
    There should also be a way to tell DotVVM you want the error page always - you can specify the useErrorPages optional argument in the app.UseDotVVM call in Startup.cs.
    Andreas Doll
    @dollhaus

    Serialised into JSON

    Ah. I knew I was missing something. I had it in my head that it was a JS conversion, not a data conversion

    Tomáš Herceg
    @tomasherceg
    @dollhaus DotVVM translates only data-binding expressions from C# (and there is a lot of limitations of what you can use there).
    For example, if you use {value: Value2.ToString("n2") + " USD"}, it will get translated to JavaScript and evaluate on the client-side.
    But if it is a C# method in the viewmodel, we cannot do that (we'd have to use web assembly which would increase the size of the page to few megabytes). Instead, we send the viewmodel to the server and run the actual C# method, and return the results to the client. It's quite similar to Blazor Server which also runs the C# on the server, but we don't have to keep a SignalR connection for the app to be running.
    Here is the list of what DotVVM can translate: https://www.dotvvm.com/docs/tutorials/basics-value-binding/2.0 (see the "Expressions Supported in Value Bindings" and ".NET Methods Supported in Value Bindings" sections).
    Lubos
    @tatran_twitter
    is this possible <div Visible='{value: _root.User.Tools[5] == "N"}'> where public string[] Tools {get;set;} ?
    Lubos
    @tatran_twitter
    image.png
    Tomáš Herceg
    @tomasherceg
    @tatran_twitter This should be supported. If it doesn't work, it's a bug we should look at.
    Lubos
    @tatran_twitter
    @tomasherceg I have tried various approaches, BOOL, INT, STRING, no luck. TextBox shows correct value, but condition fails.
    Lubos
    @tatran_twitter
    @tomasherceg The issue is in version 1.1.18.
    Anup Chaturvedi
    @anup.chaturvedi_gitlab
    Hi @tomasherceg : Need your input for a scenario , i am converting a DotVVM project to .Net core now and have multiple settings in the webconfig . In the .net Core i am having appsetting.json file which contains the same setting. Can you please confirm how to get the values of appsetting.json in the DotvvmStartup.cs file?
    Tomáš Herceg
    @tomasherceg
    @anup.chaturvedi_gitlab The best way is to use the IOptions pattern.
    1. Declare a class that represents your options. public class MyOptions { public string Opt1 { get; set; } ... }
    2. Use it in JSON file: "MyOptions": { "Opt1": "value", ... }
    3. Configure it in Startup.cs: services.Configure<MyOptions>(Configuration.GetSection("MyOptions"));
    4. Request it in the constructor of your viewodel: public MyViewModel(IOptions<MyOptions> myOptions) { this.myOptions = myOptions; }
      https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-5.0
    Tomáš Herceg
    @tomasherceg
    @tatran_twitter Oh, many apologies, but we really don't want to support 1.1.18 anymore. It is really old, and there is the old binding system which was quite messy (we rewrote it in 2.0 so it is much more maintainable). I am not sure how difficult will be to fix the issue there without breaking something else. Also, it will be even a problem for us to release the version - the build pipeline has changed a lot since that time and we'd had to do everything manually which increases the chance of error.
    Any chance that you upgrade it to 2.5?
    Or we should try to find a workaround:
    • What about having an array of objects with a string property instead: _root.User.Tools[5].Value == "N" - it may work
    • Try to use booleans instead of strings in the array - you won't need to do == on an array element which probably causes the issue
    • Also, you may use Knockout syntax for anything that is not supported in the DotVVM binding system: data-bind="visible: $root.User().Tools()[5]() == 'N'"
    Nick
    @nickgouvatsos_twitter
    Hi, I tried to migrate my old application to dotvvm, I cannot find a way to add/modified routes dynamically at runtime? Can someone help me find a way?
    Stanislav Lukeš
    @exyi
    @nickgouvatsos_twitter Even if that is possible, you shouldn't. Why do you need to add routes at runtime? Isn't it enough to make your routes generic enough with routing parameters: see Route Parameters at https://www.dotvvm.com/docs/tutorials/basics-routing/latest
    Nick
    @nickgouvatsos_twitter

    @exyi Yes i see but that does not work for my case.
    What i'm trying to do is to build a full url from my dashboard at runtime without restarting the application, for example:

    //DotvvmStartup.cs, Route Registration
    
    foreach(var cat in Data.ProductCategories) //Product Category List
    {
        //eg FullUrl output: equipment/protection/knee-elbow
        routeTable.Add(cat.ID + "_p_category", cat.FullUrl?.TrimStart('/')?.TrimEnd('/'), "Views/ProductList.dothtml");     
    
        //eg FullUrl output: equipment/protection/knee-elbow/venum-kontact-evo-knee-pads-VEV102    
        routeTable.Add(cat.ID + "_product", cat.FullUrl?.TrimStart('/')?.TrimEnd('/')+ "/{ProductUrl}", "Views/ProductList.dothtml");   
    }
    
    
    //To Get category ID in my ViewModel.cs
    
     public override Task PreRender()
     {
         if (!Context.IsPostBack) {
         int RouteID = Convert.ToInt32(Context.Route.RouteName?.Split("_")?[0]);
         } 
     {

    For my case, do you have anything else to suggest? Thanks

    Stanislav Lukeš
    @exyi
    The route table is not designed to be rebuilt at runtime (it's not thread-safe, etc), however, you could create your own Route by inheriting RouteBase. You'd hold the list of categories in the instance and implement the IsMatch and BuildUrlCore methods. You can then put the category id into the dictionary called values
    Just beware of race conditions - Asp.Net Core is a parallel environment.
    Nick
    @nickgouvatsos_twitter
    @exyi Wow thanks! Can I find an example somewhere?
    Stanislav Lukeš
    @exyi
    i don't think we have any simple example for that
    Nick
    @nickgouvatsos_twitter
    @exyi ok Thanks
    Stanislav Lukeš
    @exyi
    however , you can have a look at the DotvvmRoute class itself https://github.com/riganti/dotvvm/blob/main/src/DotVVM.Framework/Routing/DotvvmRoute.cs#L81
    Just ignore the magic done with regular expression - you will likely only need the API