The relationship between namespace and actual files layer - asp.net

OK, just as the title asked, I currently worked on a asp.net website, I found out that all the aspx and ascx files actually stay in one namespace, however there are different directory hierarchy between them. See below example.
Mainsite
| Dialogs
| | Help.ascx
| | Price.aspx
| Includes
| | QuickLink.acsx
| Members
| Orders
| Login.aspx
| Default.aspx
Like above example, all aspx ans ascx files belong to namespace Order, however Login.aspx and Price.aspx are in different directory. I mean by default when you create a aspx file in certain directory, the default namespace will inherit the directory information.
The thing is that I found at a frequently happened bug, is in Default.aspx there is ajax call to Dialogs/Price.aspx, then the error message can not find Dialogs/Dialogs/Price.aspx, it is weird.

Related

Next.js Sub-Pages for parameterized routes

Right now, my routing looks like this:
https://app.com/users opens pages/users/index.js
https://app.com/users/:userid opens pages/users/[id].js
I want to create route, for example:
https://app.com/users/:id/friends -> show all friends for the user
or even
https://app.com/users/:id/friends/:friendId -> show a specific friend
I have tried
pages
users
index.js
[id].js
friends
index.js
[friendId].js
but i can only reach users/friends and not `users/:id/friends``
How do i set my pages directory so i can use this sort of routing?
Also, I want to be able to access id and friendId in the context of getServerSideProps...
If you don't get the answer description well, pls follow the diagram I made.
If you want this https://app.com/users/:id/friends, then you should create something like this:
pages/users/index.js/[id]/index.js/friends.js
So to make this clear, you have a folder name pages (where all pages folder and files are), then you have a user folder (this takes an index.js which means user path). Now in the user folder, you have to create a folder named [id], in this folder you should create a file name index.js, this index.js stand for the :id. The last thing is to create the friend.js in the [id] folder.
Something like this.
pages ----------------- Main folder
users ------------- A folder inside `pages` folder
index.js ------- A file inside `users` folder == `https://app.com/users`
[id] ----------- A folder inside `users` folder
index.js ---- A file inside `[id]` folder ==`https://app.com/users/:id`
friends.js -- A file inside `[id]` folder == `https://app.com/users/:id/friends`
If you want something like this https://app.com/users/:id/friends/:friendId
Then you will have to do something like this:
pages ------------------------- Main folder
users --------------------- A folder inside `pages` folder
index.js --------------- A file inside `users` folder == `https://app.com/users`
[id] ------------------- A folder inside `users` folder
index.js ------------ A file inside `[id]` folder ==`https://app.com/users/:id`
[friends] -------- A folder inside `[id]` folder
index.js ------ A file inside `[friends]` folder
friendId.js --- A file inside `[friends]` folder
You can use Dynamic Routing syntax in your folders instead of a file in order to nest them (create a folder [id] instead of a file [id].js). For your specific example it would look like this:
pages
users
index.js
[id]
friends
[friendId].js

Is it possible to add properties to multiple files after they have been uploaded to artifactory?

As the title says. Due to a lack of understanding about how best to query files in artifactory I now have a situation where I have a few hundred files I need to add the same properties to.
Can this be done in bulk?
the folder structure looks like this:
repository
|
|- main folder
|
|- type
|
|- language1
|
|-sub-folder1
|-sub-folder2
|-file1
|-file2
...
...
...
Each sub-folder can have around 5 files, each language folder can have many sub-folders.
Sure it is.
You have two main options.
The first one is to use the Set Item Properties REST API on the relevant folder with the "recursiveProperties=1".
The second option, which I believe is better, will be to use the JFrog CLI to set properties on existing artifacts. This options will provide you with the ability to define a more complex logic on setting the properties.

Testing a file upload to a form in a Behat feature file

I am quite new to writing Behat test suites and I am currently trying to flesh out my existing feature file with an added test to test an uploaded file.
This is what I have come up with so far.
Scenario: Submitting a valid asset form and uploading a file
When I submit a asset form with values:
| name | type | position | active | file |
| St Andrews Release | image | 1 | 1 | /web/images/product/icon/default.jpg |
Then the form should be valid
And the entity form entity should have the following values
| name | type | position | active | file |
| St Andrews Release | image | 1 | 1 | /web/images/product/icon/default.jpg |
Failed asserting that null matches expected '/web/images/product/icon/default.jpg'.
And the entity form entity should be persisted correctly
This is the method handling the scenario:
/**
* #When I submit a asset form with values:
*/
public function iSubmitAssetFormWithValues(TableNode $table)
{
$data = $table->getColumnsHash()[0];
$this->form = $this->submitTheForm('crmpicco.asset.type', $this->entity, $data);
}
The submitTheForm method returns a Symfony\Component\Form\FormInterface.
Am I along the right lines? I am currently getting an error:
Failed asserting that null matches expected
'/web/images/product/swatch/default.jpg'.
I suggest you to create a dedicated folder structure for files which will be used in behat tests right in your application root because tests and the files used in tests must be consistent for all developers. I sometimes see people writing tests to upload files that exist on their local desktop:) My desktop and your desktop would be different hence reason the test would fail.
Structure
football #your application name/root
build
dummy
document
hello.doc
world.xls
image
test.jpg
behat.yml
Apart from other common setting, you must define file_path.
....
....
default:
extensions:
Behat\MinkExtension\Extension:
files_path: %behat.paths.base%/build/dummy/
....
....
Example Gherkin scenario
Feature: I can upload a file which is stored in my generic "dummy" folder
Scenario: I can upload image
Given I am on "/"
When I attach the file "image/test.jpg" to "league_flag"
And I press "Submit"
Then I should see "Succeeded."

<h:outputStylesheet> and relative references

I have a JSF project setup in the typical fashion:
myproject
|-- src/main/webapps
| |-- resources
| | |-- css
| | | |-- 3rdparty.css
| | |
| | |-- fonts
| | |
| | |-- myspecialfont.woff
| |
And then in my JSF html:
<h:outputStylesheet name="3rdparty.css" library="css"/>
This works well, since I can keep the directories consistent if I need to upgrade.
However, in this case, the 3rdparty.css file contains a relative reference:
#font-face {
font-family: 'Lato';
src: url('../fonts/myspecialfont.woff');
}
As h:outputStylesheet constructs the URI to use mywebapp/javax.faces.resource/3rdparty.css this will break the relative references inside it since that path will now refer to mywebapp/fonts/myspecialfont.woff.
Is there a good way to keep these locally hosted 3rd party libraries referenced by JSF to handle this kind of relative reference without resorting to manually changing the CSS?
You have two options:
Do not use outputStyleSheet and instead include it directly in your template
Modify the CSS file content (as TemarV suggested)
Unfortunately there isn't much else that can be done, because resources are rendered using a different path where-in the library & resource reference are specified as URL parameters instead of being part of the URL.
Edit: I would like to highlight a 3rd option as well - writing a custom ResourceHandler. I had to do something on these lines. You can read more about it at -
http://roguexz.blogspot.in/2013/10/jsf-2-returning-resource-url-that-is.html

URL Routing for CMS

I am developing a CMS that stores user content in a database table like this:
----------------------------------------
PageId | PageTitle(Unique) | Content
----------------------------------------
1 | PageOne | ...
2 | PageTwo | ...
3 | PageThree | ...
4 | PageFour | ...
Now I have an aspx page "SitePageFactory.aspx" at root that serves dynamic content when a querystring is passed to it, suppose /SitePageFactory.aspx?pgid=1 is passed then it serves the content for PageOne.
The concept above is working fine.
Now I want to put a step further by adding dynamic routes to this application and modify /SitePageFactory.aspx?pgid=1 to /PageOne.aspx but unable to do it at root level.
NOTE: Currently I am able to perform routing like /SitePageFactory/PageOne.aspx but I want the results at the root level.
Thanks.
You can use ASP.NET Routing to accomplish this.
Routing let's you map an url like: www.mysite.com/pages/pageone to an aspx page. The different parts in your url can be mapped to route parameters that you can access in your aspx.
Here is the MSDN documentation for routing.
You can add the folowing route:
routes.MapRoute("ViewPage",
"<PageName>",
new { controller = "Page", action = "ViewPage" }
This will map the url www.yourdomain/ to the Page controllers ViewPage method.

Resources